diff options
author | Juho Vepsalainen <bebraw@gmail.com> | 2014-06-03 15:55:24 +0300 |
---|---|---|
committer | Juho Vepsalainen <bebraw@gmail.com> | 2014-06-03 17:42:30 +0300 |
commit | b6d11d88b78149ee0d235b4f7373caf21115c863 (patch) | |
tree | 242b2786cdca2a0d592d1e0bdfab34054ac01bcb | |
parent | c803270af8c2f7d19de83f2997dbd7fe7675bd54 (diff) | |
download | gitbook-b6d11d88b78149ee0d235b4f7373caf21115c863.zip gitbook-b6d11d88b78149ee0d235b4f7373caf21115c863.tar.gz gitbook-b6d11d88b78149ee0d235b4f7373caf21115c863.tar.bz2 |
Allow book.js to be used in addition to book.json
Now it's possible to comment configuration properly and do some dynamic
things if needed.
Closes #287.
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | bin/build.js | 2 | ||||
-rw-r--r-- | lib/generate/index.js | 18 |
3 files changed, 8 insertions, 14 deletions
@@ -32,7 +32,7 @@ Options for commands `build` and `serve` are: ``` -o, --output <directory> Path to output directory, defaults to ./_book -f, --format <name> Change generation format, defaults to site, availables are: site, page, ebook, json ---config <config file> Configuration file to use, defaults to book.json +--config <config file> Configuration file to use, defaults to book.js or book.json ``` GitBook loads the default configuration from a `book.json` file in the repository if it exists. diff --git a/bin/build.js b/bin/build.js index 35018cb..4bb6bb4 100644 --- a/bin/build.js +++ b/bin/build.js @@ -12,7 +12,7 @@ var buildCommand = function(command) { return command .option('-o, --output <directory>', 'Path to output directory, defaults to ./_book') .option('-f, --format <name>', 'Change generation format, defaults to site, availables are: '+_.keys(generators).join(", ")) - .option('--config <config file>', 'Configuration file to use, defualt to book.json') + .option('--config <config file>', 'Configuration file to use, defaults to book.js or book.json') }; diff --git a/lib/generate/index.js b/lib/generate/index.js index 520981c..1fb372e 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -54,7 +54,7 @@ var generate = function(options) { "output": null, // Config file (relative to input) - "configFile": "book.json", + "configFile": "book", // Output generator "generator": "site", @@ -93,17 +93,11 @@ var generate = function(options) { // Read config file .then(function() { - return fs.readFile(path.resolve(options.input, options.configFile)) - .then(function(_config) { - // Extend current config - _config = JSON.parse(_config); - _config = _.omit(_config, 'input', 'configFile', 'defaultsPlugins'); - - _.extend(options, _config); - }, function() { - // No config file: not a big deal - return Q(); - }); + var _config = require(path.resolve(options.input, options.configFile)); + + _.extend(options, _.omit(_config, 'input', 'configFile', 'defaultsPlugins')); + + return Q(); }) // Read readme |