diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-09-15 13:16:26 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-09-15 13:16:26 +0200 |
commit | fe3a9c33d0395ea9747ab8ef2fec24e81fc92715 (patch) | |
tree | cfa372c70a40f532ed93b3dc9992ef30d0f2b3bb /lib/index.js | |
parent | d83116b88ffbe87fb09c2da322ddade7b7f04e24 (diff) | |
download | gitbook-fe3a9c33d0395ea9747ab8ef2fec24e81fc92715.zip gitbook-fe3a9c33d0395ea9747ab8ef2fec24e81fc92715.tar.gz gitbook-fe3a9c33d0395ea9747ab8ef2fec24e81fc92715.tar.bz2 |
Improve code style for book.js and index.js
Diffstat (limited to 'lib/index.js')
-rw-r--r-- | lib/index.js | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/index.js b/lib/index.js index b5aa06d..89d5d3c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,11 +1,10 @@ var Q = require("q"); var _ = require("lodash"); var path = require("path"); -var tinylr = require('tiny-lr'); -var color = require('bash-color'); +var tinylr = require("tiny-lr"); +var color = require("bash-color"); var Book = require("./book"); -var Plugin = require("./plugin"); var Server = require("./utils/server"); var stringUtils = require("./utils/string"); var watch = require("./utils/watch"); @@ -42,10 +41,10 @@ module.exports = { var output = args[1] || path.join(input, "_book"); var book = new Book(input, _.extend({}, { - 'config': { - 'output': output + "config": { + "output": output }, - 'logLevel': kwargs.log + "logLevel": kwargs.log })); return book.parse() @@ -71,7 +70,7 @@ module.exports = { var output = args[1]; var book = new Book(input, _.extend({}, { - 'logLevel': kwargs.log + "logLevel": kwargs.log })); return book.parse() @@ -116,7 +115,7 @@ module.exports = { // Init livereload server var lrServer = tinylr({}); - var lrPath = undefined; + var lrPath; var generate = function() { if (server.isRunning()) console.log("Stopping server"); @@ -124,10 +123,10 @@ module.exports = { return server.stop() .then(function() { var book = new Book(input, _.extend({}, { - 'config': { - 'defaultsPlugins': ["livereload"] + "config": { + "defaultsPlugins": ["livereload"] }, - 'logLevel': kwargs.log + "logLevel": kwargs.log })); return book.parse() @@ -138,10 +137,10 @@ module.exports = { }) .then(function(book) { console.log(); - console.log('Starting server ...'); + console.log("Starting server ..."); return server.start(book.options.output, kwargs.port) .then(function() { - console.log('Serving book on http://localhost:'+kwargs.port); + console.log("Serving book on http://localhost:"+kwargs.port); if (lrPath) { // trigger livereload @@ -159,18 +158,18 @@ module.exports = { // set livereload path lrPath = filepath; console.log("Restart after change in file", filepath); - console.log(''); + console.log(""); return generate(); - }) - }) + }); + }); }); }; return Q.nfcall(lrServer.listen.bind(lrServer), kwargs.lrport) .then(function() { - console.log('Live reload server started on port:', kwargs.lrport); - console.log('Press CTRL+C to quit ...'); - console.log('') + console.log("Live reload server started on port:", kwargs.lrport); + console.log("Press CTRL+C to quit ..."); + console.log(""); return generate(); }); } @@ -179,7 +178,7 @@ module.exports = { { name: "install [book]", description: "install plugins dependencies", - exec: function(args, kwargs) { + exec: function(args) { var input = args[0] || process.cwd(); var book = new Book(input); @@ -198,7 +197,7 @@ module.exports = { { name: "init [directory]", description: "create files and folders based on contents of SUMMARY.md", - exec: function(args, kwargs) { + exec: function(args) { return Book.init(args[0] || process.cwd()) .then(function(){ console.log(""); |