diff options
Diffstat (limited to 'lib/generate/index.js')
-rw-r--r-- | lib/generate/index.js | 69 |
1 files changed, 3 insertions, 66 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index 53de646..362d613 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -7,6 +7,7 @@ var swig = require('./template'); var fs = require("./fs"); var parse = require("../parse"); var Plugin = require("./plugin"); +var defaultConfig = require("./config"); var generators = { "site": require("./site"), @@ -25,7 +26,7 @@ var containsFiles = function(dir, files) { .then(_.all); }; -// TEst if generator exists +// Test if generator exists var checkGenerator = function(options) { if (!generators[options.generator]) { return Q.reject(new Error("Invalid generator (availables are: "+_.keys(generators).join(", ")+")")); @@ -48,40 +49,7 @@ var loadGenerator = function(options) { var generate = function(options) { // Set defaults to options - options = _.defaults(options || {}, { - // Folders to use - "input": null, - "output": null, - - // Config file (relative to input) - "configFile": "book", - - // Output generator - "generator": "site", - - // Book title, keyword, description - "title": null, - "description": null, - - // Origin github repository id - "github": null, - "githubHost": 'https://github.com/', - - // Theming - "theme": path.resolve(__dirname, '../../theme'), - - // Plugins - "plugins": [], - "pluginsConfig": {}, - "defaultsPlugins": [], // Default plugins that can't be set in book.json - - // Links - "links": { - "about": null, - "issues": null, - "contribue": null, - } - }); + options = _.merge(options || {}, defaultConfig, _.defaults); // Validate options if (!options.input) { @@ -217,37 +185,6 @@ var generateBook = function(options) { return fs.remove(options.output); }) - // Get repo's URL - .then(function() { - // Git deactivated - if(options.github === false) { - options.github = null; - return null; - } else if(options.github) { - // Git already specified in options - options.github = ( - // Support URLs in "github" entry of book.json - parse.git.githubID(options.github) || - - // Fallback - options.github - ); - return; - } - - // Try auto detecting - 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 = repoId; - }); - }) - .then(function() { return fs.mkdirp(options.output); }) |