diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-30 11:33:31 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-30 11:33:31 +0100 |
commit | f7039a174a1a387750daf57991c122d7becc27ef (patch) | |
tree | 67bc333c6ff6f2a284d66a76c2a800437956cd81 /lib/configuration.js | |
parent | 56907044443ba42eaa0faa7733d90d41cf513966 (diff) | |
download | gitbook-f7039a174a1a387750daf57991c122d7becc27ef.zip gitbook-f7039a174a1a387750daf57991c122d7becc27ef.tar.gz gitbook-f7039a174a1a387750daf57991c122d7becc27ef.tar.bz2 |
Add warning message when gitbook version to use is not fixed
Diffstat (limited to 'lib/configuration.js')
-rw-r--r-- | lib/configuration.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/configuration.js b/lib/configuration.js index 678bfe7..ad4f445 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -2,7 +2,9 @@ var _ = require("lodash"); var Q = require("q"); var path = require("path"); var npmi = require('npmi'); +var semver = require('semver'); +var pkg = require('../package.json'); var fs = require("./utils/fs"); // Default plugins added to each books @@ -98,6 +100,13 @@ Configuration.prototype.load = function() { that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins || ""); that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins); that.options.plugins = _.uniq(that.options.plugins, "name"); + + if (!semver.satisfies(pkg.version, that.options.gitbook)) { + throw "GitBook version doesn't satisfy version required by the book: "+that.options.gitbook; + } + if (that.options.gitbook == "*") { + that.book.log.warn.ln("you should specify a gitbook version to use in your book.json, for example: "+(_.first(pkg.version.split("."))+".x.x")); + } }); }; @@ -164,6 +173,9 @@ Configuration.DEFAULT = { "isbn": null, "language": "en", + // version of gitbook to use + "gitbook": "*", + // Structure "structure": { "langs": "LANGS.md", |