summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-26 12:05:50 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-26 12:05:50 +0100
commit795da31af81c1dd8740a9129dc0eb959b9852ee8 (patch)
treebd28dfabc5e51f9ae0778eb98b4bb05675b7fb7b /lib
parentf70c29fea5ce935213683c2f3de952d8a164df4e (diff)
downloadgitbook-795da31af81c1dd8740a9129dc0eb959b9852ee8.zip
gitbook-795da31af81c1dd8740a9129dc0eb959b9852ee8.tar.gz
gitbook-795da31af81c1dd8740a9129dc0eb959b9852ee8.tar.bz2
Add warning message about deprecated hooks
Diffstat (limited to 'lib')
-rw-r--r--lib/plugin.js13
-rw-r--r--lib/utils/logger.js8
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/plugin.js b/lib/plugin.js
index f558bf8..3d60321 100644
--- a/lib/plugin.js
+++ b/lib/plugin.js
@@ -29,6 +29,9 @@ var Plugin = function(book, name) {
// Type of plugins resources
Plugin.RESOURCES = ["js", "css"];
+Plugin.HOOKS = [
+ "init", "finish"
+]
// Load from a name
Plugin.prototype.load = function(name, baseDir) {
@@ -100,13 +103,21 @@ Plugin.prototype.getResources = function(base) {
// Test if it's a valid plugin
Plugin.prototype.isValid = function() {
- return (
+ var that = this;
+ var isValid = (
this.packageInfos &&
this.packageInfos.name &&
this.packageInfos.engines &&
this.packageInfos.engines.gitbook &&
semver.satisfies(pkg.version, this.packageInfos.engines.gitbook)
);
+
+ // Valid hooks
+ _.each(this.infos.hooks, function(hook, hookName) {
+ that.book.log.warn.ln("Hook '"+hookName+" 'used by plugin '"+that.packageInfos.name+"' has been removed or is deprecated");
+ });
+
+ return isValid;
};
// Resolve file path
diff --git a/lib/utils/logger.js b/lib/utils/logger.js
index 927048b..9ef9ccf 100644
--- a/lib/utils/logger.js
+++ b/lib/utils/logger.js
@@ -5,14 +5,14 @@ var color = require('bash-color');
var LEVELS = {
DEBUG: 0,
INFO: 1,
- WARNING: 2,
+ WARN: 2,
ERROR: 3
};
var COLORS = {
DEBUG: color.purple,
INFO: color.cyan,
- WARNING: color.yellow,
+ WARN: color.yellow,
ERROR: color.red
};
@@ -53,6 +53,8 @@ module.exports = function(_write, logLevel) {
return logger.write(msg);
};
logger.logLn = function() {
+ if (lastChar != '\n') logger.write("\n");
+
var args = Array.prototype.slice.apply(arguments);
args.push("\n");
logger.log.apply(logger, args);
@@ -65,7 +67,7 @@ module.exports = function(_write, logLevel) {
if (arguments.length > 1) {
logger.logLn(level, color.green('>> ') + msg.trim().replace(/\n/g, color.green('\n>> ')));
} else {
- logger.logLn(level, color.green("OK"));
+ logger.log(level, color.green("OK"), "\n");
}
};