diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-23 15:05:32 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-23 15:05:32 +0100 |
commit | f052aacee1140f211ebb9454157fa7a3604005cf (patch) | |
tree | f784d8b9fd70bd94b754e13d26e6f6dd548b9908 /lib/cli | |
parent | 13e2ff8035d9a93e4ee8eb79ec71ac92e6f2bf7e (diff) | |
download | gitbook-f052aacee1140f211ebb9454157fa7a3604005cf.zip gitbook-f052aacee1140f211ebb9454157fa7a3604005cf.tar.gz gitbook-f052aacee1140f211ebb9454157fa7a3604005cf.tar.bz2 |
Add .gitbook to locate book inside repository
Diffstat (limited to 'lib/cli')
-rw-r--r-- | lib/cli/helper.js | 13 | ||||
-rw-r--r-- | lib/cli/index.js | 23 |
2 files changed, 18 insertions, 18 deletions
diff --git a/lib/cli/helper.js b/lib/cli/helper.js index 9510b49..e62c8d9 100644 --- a/lib/cli/helper.js +++ b/lib/cli/helper.js @@ -9,6 +9,8 @@ var JSONOutput = require('../output/json'); var WebsiteOutput = require('../output/website'); var EBookOutput = require('../output/ebook'); +var nodeFS = new NodeFS(); + var LOG_OPTION = { name: 'log', description: 'Minimum log level to display', @@ -39,14 +41,12 @@ var FORMATS = { function bookCmd(fn) { return function(args, kwargs) { var input = path.resolve(args[0] || process.cwd()); - var book = new Book({ - fs: new NodeFS(), - root: input, - + return Book.setup(nodeFS, input, { logLevel: kwargs.log + }) + .then(function(book) { + return fn(book, args.slice(1), kwargs); }); - - return fn(book, args.slice(1), kwargs); }; } @@ -94,6 +94,7 @@ function ebookCmd(format) { } module.exports = { + nodeFS: nodeFS, bookCmd: bookCmd, outputCmd: outputCmd, ebookCmd: ebookCmd, diff --git a/lib/cli/index.js b/lib/cli/index.js index 78c5286..0b2366a 100644 --- a/lib/cli/index.js +++ b/lib/cli/index.js @@ -114,22 +114,21 @@ module.exports = { // Generate the book .then(function() { - var book = new Book({ - fs: new NodeFS(), - root: input, + return Book.setup(helper.nodeFS, input, { 'config': { 'defaultsPlugins': ['livereload'] }, 'logLevel': kwargs.log - }); - - return book.parse() - .then(function() { - var Out = helper.FORMATS[kwargs.format]; - var output = new Out(book); - - return output.generate() - .thenResolve(output); + }) + .then(function(book) { + return book.parse() + .then(function() { + var Out = helper.FORMATS[kwargs.format]; + var output = new Out(book); + + return output.generate() + .thenResolve(output); + }); }); }) |