summaryrefslogtreecommitdiffstats
path: root/lib/config/index.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-25 14:17:31 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-25 14:17:31 +0100
commit9215edc0a08e909763bae67ce7babb46fe655a4d (patch)
tree3797f331793a76b838b8e04777472676b63d3ecc /lib/config/index.js
parent25ae21dae35e42268be28d9efa7f8175841c7dcc (diff)
downloadgitbook-9215edc0a08e909763bae67ce7babb46fe655a4d.zip
gitbook-9215edc0a08e909763bae67ce7babb46fe655a4d.tar.gz
gitbook-9215edc0a08e909763bae67ce7babb46fe655a4d.tar.bz2
Remove option defaultPlugins and simplify loading
Diffstat (limited to 'lib/config/index.js')
-rw-r--r--lib/config/index.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/config/index.js b/lib/config/index.js
index 272e92a..7f75733 100644
--- a/lib/config/index.js
+++ b/lib/config/index.js
@@ -22,13 +22,15 @@ function Config(book, baseConfig) {
this.log = book.log;
this.path = '';
- this.replace(baseConfig || {});
+ this.baseConfig = baseConfig || {};
+ this.replace({});
}
// Load configuration of the book
// and verify that the configuration is satisfying
Config.prototype.load = function() {
var that = this;
+ var isLanguageBook = this.book.isLanguageBook();
// Try all potential configuration file
return Promise.some(CONFIG_FILES, function(filename) {
@@ -47,19 +49,19 @@ Config.prototype.load = function() {
});
})
.then(function() {
- if (!that.book.isLanguageBook()) {
+ if (!isLanguageBook) {
if (!gitbook.satisfies(that.options.gitbook)) {
throw new Error('GitBook version doesn\'t satisfy version required by the book: '+that.options.gitbook);
}
if (that.options.gitbook != '*' && !semver.satisfies(semver.inc(gitbook.version, 'patch'), that.options.gitbook)) {
that.log.warn.ln('gitbook version specified in your book.json might be too strict for future patches, \''+(_.first(gitbook.version.split('.'))+'.x.x')+'\' is more adequate');
}
- }
- that.options.plugins = plugins.toList(that.options.plugins);
- that.options.defaultsPlugins = plugins.toList(that.options.defaultsPlugins || '', false);
- that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins);
- that.options.plugins = _.uniq(that.options.plugins, 'name');
+ that.options.plugins = plugins.toList(that.options.plugins);
+ } else {
+ // Multilingual book should inherits the plugins list from parent
+ that.options.plugins = that.book.parent.config.get('plugins');
+ }
that.options.gitbook = gitbook.version;
});
@@ -69,6 +71,10 @@ Config.prototype.load = function() {
Config.prototype.replace = function(options) {
var that = this;
+ // Extend base config
+ options = _.defaults(_.cloneDeep(options), this.baseConfig);
+
+ // Validate the config
this.options = validator.validate(options);
// options.input == book.root