diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-08-09 14:47:12 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-08-11 07:36:49 -0700 |
commit | d07b9450b12634ad61c57264b277fadf47290ac7 (patch) | |
tree | 2d50c5446f7f5ae5e4a15fbf6f62936ecf320829 | |
parent | c30b431b7b87b459a6e09c44a1ba767d14231f8b (diff) | |
download | gitbook-d07b9450b12634ad61c57264b277fadf47290ac7.zip gitbook-d07b9450b12634ad61c57264b277fadf47290ac7.tar.gz gitbook-d07b9450b12634ad61c57264b277fadf47290ac7.tar.bz2 |
Fix defaults for configuration
-rw-r--r-- | lib/generate/config.js | 10 | ||||
-rw-r--r-- | lib/generate/index.js | 11 |
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/generate/config.js b/lib/generate/config.js index 798bedc..13a95af 100644 --- a/lib/generate/config.js +++ b/lib/generate/config.js @@ -1,7 +1,8 @@ +var _ = require('lodash'); var path = require('path'); // Default configuration for gitbook -module.exports = { +var CONFIG = { // Folders to use for output // Caution: it overrides the value from the command line // It's not advised this option in the book.json @@ -89,3 +90,10 @@ module.exports = { } }; +module.exports = { + CONFIG: CONFIG, + defaults: function(options) { + return _.merge(options || {}, CONFIG, _.defaults); + } +} + diff --git a/lib/generate/index.js b/lib/generate/index.js index 362d613..c9d6e5c 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -49,7 +49,14 @@ var loadGenerator = function(options) { var generate = function(options) { // Set defaults to options - options = _.merge(options || {}, defaultConfig, _.defaults); + options = _.defaults(options || {}, { + // Config file (relative to input) + "configFile": "book", + + // Output generator + "generator": "site" + }); + //options = _.merge(options || {}, defaultConfig, _.defaults); // Validate options if (!options.input) { @@ -70,6 +77,8 @@ var generate = function(options) { // No config file: not a big deal return Q(); } + + options = defaultConfig.defaults(options); }) // Read readme |