diff options
Diffstat (limited to 'packages/gitbook/src/cli')
-rw-r--r-- | packages/gitbook/src/cli/build.js | 4 | ||||
-rw-r--r-- | packages/gitbook/src/cli/buildEbook.js | 8 | ||||
-rw-r--r-- | packages/gitbook/src/cli/install.js | 2 | ||||
-rw-r--r-- | packages/gitbook/src/cli/options.js | 2 | ||||
-rw-r--r-- | packages/gitbook/src/cli/parse.js | 4 | ||||
-rw-r--r-- | packages/gitbook/src/cli/serve.js | 20 | ||||
-rw-r--r-- | packages/gitbook/src/cli/server.js | 14 | ||||
-rw-r--r-- | packages/gitbook/src/cli/watch.js | 18 |
8 files changed, 36 insertions, 36 deletions
diff --git a/packages/gitbook/src/cli/build.js b/packages/gitbook/src/cli/build.js index 3f5c937..1816326 100644 --- a/packages/gitbook/src/cli/build.js +++ b/packages/gitbook/src/cli/build.js @@ -22,12 +22,12 @@ module.exports = { const Generator = Output.getGenerator(kwargs.format); return Parse.parseBook(book) - .then(function(resultBook) { + .then((resultBook) => { return Output.generate(Generator, resultBook, { root: outputFolder }); }) - .fin(function() { + .fin(() => { if (kwargs.timing) timing.dump(book.getLogger()); }); } diff --git a/packages/gitbook/src/cli/buildEbook.js b/packages/gitbook/src/cli/buildEbook.js index 56e63f8..5f941ec 100644 --- a/packages/gitbook/src/cli/buildEbook.js +++ b/packages/gitbook/src/cli/buildEbook.js @@ -31,7 +31,7 @@ module.exports = function(format) { const Generator = Output.getGenerator('ebook'); return Parse.parseBook(book) - .then(function(resultBook) { + .then((resultBook) => { return Output.generate(Generator, resultBook, { root: outputFolder, format @@ -39,12 +39,12 @@ module.exports = function(format) { }) // Extract ebook file - .then(function(output) { + .then((output) => { const book = output.getBook(); const languages = book.getLanguages(); if (book.isMultilingual()) { - return Promise.forEach(languages.getList(), function(lang) { + return Promise.forEach(languages.getList(), (lang) => { const langID = lang.getID(); const langOutputFile = path.join( @@ -67,7 +67,7 @@ module.exports = function(format) { }) // Log end - .then(function(count) { + .then((count) => { logger.info.ok(count + ' file(s) generated'); logger.debug('cleaning up... '); diff --git a/packages/gitbook/src/cli/install.js b/packages/gitbook/src/cli/install.js index 6af4013..2e8d110 100644 --- a/packages/gitbook/src/cli/install.js +++ b/packages/gitbook/src/cli/install.js @@ -14,7 +14,7 @@ module.exports = { const book = getBook(args, kwargs); return Parse.parseConfig(book) - .then(function(resultBook) { + .then((resultBook) => { return Plugins.installPlugins(resultBook); }); } diff --git a/packages/gitbook/src/cli/options.js b/packages/gitbook/src/cli/options.js index d643f91..ac51360 100644 --- a/packages/gitbook/src/cli/options.js +++ b/packages/gitbook/src/cli/options.js @@ -5,7 +5,7 @@ const logOptions = { description: 'Minimum log level to display', values: Logger.LEVELS .keySeq() - .map(function(s) { + .map((s) => { return s.toLowerCase(); }).toJS(), defaults: 'info' diff --git a/packages/gitbook/src/cli/parse.js b/packages/gitbook/src/cli/parse.js index 3d38fe7..a6aee08 100644 --- a/packages/gitbook/src/cli/parse.js +++ b/packages/gitbook/src/cli/parse.js @@ -42,7 +42,7 @@ function printMultingualBook(book) { logger.info.ln(languages.size + ' languages'); - languages.forEach(function(lang) { + languages.forEach((lang) => { logger.info.ln('Language:', lang.getTitle()); printBook(books.get(lang.getID())); logger.info.ln(''); @@ -60,7 +60,7 @@ module.exports = { const logger = book.getLogger(); return Parse.parseBook(book) - .then(function(resultBook) { + .then((resultBook) => { const rootFolder = book.getRoot(); const contentFolder = book.getContentRoot(); diff --git a/packages/gitbook/src/cli/serve.js b/packages/gitbook/src/cli/serve.js index 6397c2e..243af16 100644 --- a/packages/gitbook/src/cli/serve.js +++ b/packages/gitbook/src/cli/serve.js @@ -20,7 +20,7 @@ let server, lrServer, lrPath; function waitForCtrlC() { const d = Promise.defer(); - process.on('SIGINT', function() { + process.on('SIGINT', () => { d.resolve(); }); @@ -43,9 +43,9 @@ function generateBook(args, kwargs) { if (server.isRunning()) console.log('Stopping server'); return server.stop() - .then(function() { + .then(() => { return Parse.parseBook(book) - .then(function(resultBook) { + .then((resultBook) => { if (hasLiveReloading) { // Enable livereload plugin let config = resultBook.getConfig(); @@ -58,12 +58,12 @@ function generateBook(args, kwargs) { }); }); }) - .then(function() { + .then(() => { console.log(); console.log('Starting server ...'); return server.start(outputFolder, port); }) - .then(function() { + .then(() => { console.log('Serving book on http://localhost:' + port); if (lrPath && hasLiveReloading) { @@ -79,13 +79,13 @@ function generateBook(args, kwargs) { open('http://localhost:' + port, browser); } }) - .then(function() { + .then(() => { if (!hasWatch) { return waitForCtrlC(); } return watch(book.getRoot()) - .then(function(filepath) { + .then((filepath) => { // set livereload path lrPath = filepath; console.log('Restart after change in file', filepath); @@ -138,21 +138,21 @@ module.exports = { const hasLiveReloading = kwargs['live']; return Promise() - .then(function() { + .then(() => { if (!hasWatch || !hasLiveReloading) { return; } lrServer = tinylr({}); return Promise.nfcall(lrServer.listen.bind(lrServer), kwargs.lrport) - .then(function() { + .then(() => { console.log('Live reload server started on port:', kwargs.lrport); console.log('Press CTRL+C to quit ...'); console.log(''); }); }) - .then(function() { + .then(() => { return generateBook(args, kwargs); }); } diff --git a/packages/gitbook/src/cli/server.js b/packages/gitbook/src/cli/server.js index c494efc..930e5c0 100644 --- a/packages/gitbook/src/cli/server.js +++ b/packages/gitbook/src/cli/server.js @@ -31,7 +31,7 @@ class Server extends events.EventEmitter { if (!this.isRunning()) return Promise(); const d = Promise.defer(); - this.running.close(function(err) { + this.running.close((err) => { that.running = null; that.emit('state', false); @@ -57,10 +57,10 @@ class Server extends events.EventEmitter { if (that.isRunning()) pre = this.stop(); return pre - .then(function() { + .then(() => { const d = Promise.defer(); - that.running = http.createServer(function(req, res) { + that.running = http.createServer((req, res) => { // Render error function error(err) { res.statusCode = err.status || 500; @@ -69,7 +69,7 @@ class Server extends events.EventEmitter { // Redirect to directory's index.html function redirect() { - const resultURL = urlTransform(req.url, function(parsed) { + const resultURL = urlTransform(req.url, (parsed) => { parsed.pathname += '/'; return parsed; }); @@ -90,15 +90,15 @@ class Server extends events.EventEmitter { .pipe(res); }); - that.running.on('connection', function(socket) { + that.running.on('connection', (socket) => { that.sockets.push(socket); socket.setTimeout(4000); - socket.on('close', function() { + socket.on('close', () => { that.sockets.splice(that.sockets.indexOf(socket), 1); }); }); - that.running.listen(port, function(err) { + that.running.listen(port, (err) => { if (err) return d.reject(err); that.port = port; diff --git a/packages/gitbook/src/cli/watch.js b/packages/gitbook/src/cli/watch.js index e1d453c..9571ef5 100644 --- a/packages/gitbook/src/cli/watch.js +++ b/packages/gitbook/src/cli/watch.js @@ -2,14 +2,14 @@ const path = require('path'); const chokidar = require('chokidar'); const Promise = require('../utils/promise'); -const parsers = require('../parsers'); +const { FILE_EXTENSIONS } = require('../parsers'); /** - Watch a folder and resolve promise once a file is modified - - @param {String} dir - @return {Promise} -*/ + * Watch a folder and resolve promise once a file is modified + * + * @param {String} dir + * @return {Promise} + */ function watch(dir) { const d = Promise.defer(); dir = path.resolve(dir); @@ -19,7 +19,7 @@ function watch(dir) { ]; // Watch all parsable files - parsers.extensions.forEach(function(ext) { + FILE_EXTENSIONS.forEach((ext) => { toWatch.push('**/*' + ext); }); @@ -29,12 +29,12 @@ function watch(dir) { ignoreInitial: true }); - watcher.once('all', function(e, filepath) { + watcher.once('all', (e, filepath) => { watcher.close(); d.resolve(filepath); }); - watcher.once('error', function(err) { + watcher.once('error', (err) => { watcher.close(); d.reject(err); |