diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-28 20:29:36 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-28 20:29:36 +0200 |
commit | 23056fc85da957d6f63808e59e13d8bd646a215d (patch) | |
tree | 022bdc72e87ef34677951b6743df291522661899 /lib/generate/index.js | |
parent | 5f1bfc02805e074ab47bc8966410cf8042363c48 (diff) | |
download | gitbook-23056fc85da957d6f63808e59e13d8bd646a215d.zip gitbook-23056fc85da957d6f63808e59e13d8bd646a215d.tar.gz gitbook-23056fc85da957d6f63808e59e13d8bd646a215d.tar.bz2 |
Use a global configuration file for a book (default to book.json)
Diffstat (limited to 'lib/generate/index.js')
-rw-r--r-- | lib/generate/index.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index 0e7eb6c..898e71f 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -31,6 +31,9 @@ var generate = function(options) { input: null, output: null, + // Config file (relative to input) + configFile: "book.json", + // Output generator generator: "site", @@ -63,6 +66,21 @@ var generate = function(options) { // Clean output folder return fs.remove(options.output) + // 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'); + + _.extend(options, _config); + }, function() { + // No config file: not a big deal + return Q(); + }) + }) + // Get repo's URL .then(function() { return parse.git.url(options.input) |