diff options
Diffstat (limited to 'lib/generate/index.js')
-rw-r--r-- | lib/generate/index.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index 0c3e693..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,35 @@ 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) + .then(function(_url) { + // Get ID of repo + return parse.git.githubID(_url); + }, function(err) { + return null; + }) + .then(function(repoId) { + options.github = options.github || repoId; + }); + }) + .then(function() { return fs.mkdirp(options.output); }) |