From ad4ed09fae64c9c35f03760c11769cf41d81df70 Mon Sep 17 00:00:00 2001 From: jossemarGT Date: Mon, 12 Oct 2015 20:11:52 -0600 Subject: [PATCH] Adding disableAutoOpen flag to use this module seamlessly in a docker container --- .eslintrc | 10 ++++++++++ bin/cli.js | 8 +++++--- bin/server.js | 9 ++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..d398e5f --- /dev/null +++ b/.eslintrc @@ -0,0 +1,10 @@ +{ + "env": { + "node": true + }, + "rules": { + "strict": 0, + "quotes": [1, "single"], + "semi": [1, "always"] + } +} diff --git a/bin/cli.js b/bin/cli.js index 233d97d..c708b92 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -24,6 +24,7 @@ program .option('-r, --print [filename]', 'Print') .option('-s, --separator [separator]', 'Slide separator') .option('-v, --verticalSeparator [vertical separator]', 'Vertical slide separator') + .option('--disableAutoOpen', 'Disable to automatically open your web browser') .parse(process.argv); if(program.args.length > 2) { @@ -35,7 +36,7 @@ var pathArg = program.args[0]; // TODO: fix user can have own demo file/directory if(pathArg === 'demo') { - basePath = __dirname + '/../demo'; + basePath = path.join(__dirname, '../demo'); } else if(pathArg) { @@ -79,7 +80,7 @@ var manifestPath = path.join(basePath, 'reveal.json'); if(fs.existsSync(manifestPath) && fs.statSync(manifestPath).isFile(manifestPath)) { try { var options = require(manifestPath); - if(typeof options === "object") { + if(typeof options === 'object') { revealOptions = options; } } catch(err) { @@ -107,5 +108,6 @@ server.start({ separator: program.separator, verticalSeparator: program.verticalSeparator, printFile: program.print, - revealOptions: revealOptions + revealOptions: revealOptions, + openWebBrowser: !program.disableAutoOpen }); diff --git a/bin/server.js b/bin/server.js index 644b69b..48213f6 100644 --- a/bin/server.js +++ b/bin/server.js @@ -50,6 +50,7 @@ var startMarkdownServer = function(options) { opts.verticalSeparator = options.verticalSeparator || opts.verticalSeparator; opts.printMode = typeof printFile !== 'undefined' && printFile || opts.printMode; opts.revealOptions = options.revealOptions || {}; + opts.openWebBrowser = options.openWebBrowser; app.use('/lib/css/' + opts.highlightTheme + '.css', staticDir(path.join(serverBasePath, 'node_modules', 'highlight.js', 'styles', opts.highlightTheme + '.css'))); @@ -86,7 +87,9 @@ var startMarkdownServer = function(options) { }); } else { console.log('Reveal-server started, opening at http://' + opts.host + ':' + opts.port); - open(initialFilePath); + if(opts.openWebBrowser){ + open(initialFilePath); + } } }; @@ -140,9 +143,9 @@ var render = function(res, markdown) { var generateMarkdownListing = function(userBasePath) { var list = []; - glob.sync("**/*.md", { + glob.sync('**/*.md', { cwd: userBasePath || opts.userBasePath - }).forEach(function(file) { + }).forEach(function(file) { list.push('' + file + ''); });