summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/gitbook.js4
-rw-r--r--lib/generate/generator.js1
-rw-r--r--lib/generate/index.js31
-rw-r--r--lib/generate/plugin.js3
4 files changed, 21 insertions, 18 deletions
diff --git a/bin/gitbook.js b/bin/gitbook.js
index ca68142..84f5a8f 100755
--- a/bin/gitbook.js
+++ b/bin/gitbook.js
@@ -45,7 +45,9 @@ build.command(prog.command('serve [source_dir]'))
server.stop()
.then(function() {
- return build.folder(dir, options);
+ return build.folder(dir, _.extend(options || {}, {
+ defaultsPlugins: ["livereload"]
+ }));
})
.then(function(_options) {
console.log();
diff --git a/lib/generate/generator.js b/lib/generate/generator.js
index ecd646c..2c4cb44 100644
--- a/lib/generate/generator.js
+++ b/lib/generate/generator.js
@@ -9,6 +9,7 @@ var BaseGenerator = function(options) {
this.options = options;
this.options.plugins = Plugin.normalizeNames(this.options.plugins);
+ this.options.plugins = _.union(this.options.plugins, this.options.defaultsPlugins);
this.plugins = [];
};
diff --git a/lib/generate/index.js b/lib/generate/index.js
index 8c6450c..8bb7052 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -64,6 +64,7 @@ var generate = function(options) {
// Plugins
"plugins": [],
"pluginsConfig": {},
+ "defaultsPlugins": [], // Default plugins that can't be set in book.json
// Links
"links": {
@@ -86,6 +87,21 @@ var generate = function(options) {
// Check files to get folder type (book, multilanguage book or neither)
return Q()
+ // 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();
+ });
+ })
+
// Read readme
.then(function() {
return fs.readFile(path.join(options.input, "README.md"), "utf-8")
@@ -177,21 +193,6 @@ var generateBook = 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');
-
- _.extend(options, _config);
- }, function() {
- // No config file: not a big deal
- return Q();
- });
- })
-
// Clean output folder
.then(function() {
return fs.remove(options.output);
diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js
index 5804f91..1edb62d 100644
--- a/lib/generate/plugin.js
+++ b/lib/generate/plugin.js
@@ -186,8 +186,7 @@ Plugin.fromList = function(names, root) {
// Default plugins
Plugin.defaults = [
"mixpanel",
- "mathjax",
- "livereload"
+ "mathjax"
];
module.exports = Plugin;