diff options
Diffstat (limited to 'lib/plugin.js')
-rw-r--r-- | lib/plugin.js | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/plugin.js b/lib/plugin.js index 5e1c427..e3ac7bc 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,12 +1,12 @@ -var _ = require("lodash"); -var Q = require("q"); -var semver = require("semver"); -var path = require("path"); -var url = require("url"); -var fs = require("./utils/fs"); -var resolve = require("resolve"); +var _ = require('lodash'); +var Q = require('q'); +var semver = require('semver'); +var path = require('path'); +var url = require('url'); +var fs = require('./utils/fs'); +var resolve = require('resolve'); -var pkg = require("../package.json"); +var pkg = require('../package.json'); var Plugin = function(book, name) { this.book = book; @@ -18,8 +18,8 @@ var Plugin = function(book, name) { _.bindAll(this); _.each([ - "gitbook-plugin-"+name, - "gitbook-"+name, + 'gitbook-plugin-'+name, + 'gitbook-'+name, name, ], function(_name) { // Load from the book @@ -31,15 +31,15 @@ var Plugin = function(book, name) { }; // Type of plugins resources -Plugin.RESOURCES = ["js", "css"]; +Plugin.RESOURCES = ['js', 'css']; Plugin.HOOKS = [ - "init", "finish", "finish:before", "page", "page:before" + 'init', 'finish', 'finish:before', 'config', 'page', 'page:before' ]; // Load from a name Plugin.prototype.load = function(name, baseDir) { try { - var res = resolve.sync(name+"/package.json", { basedir: baseDir }); + var res = resolve.sync(name+'/package.json', { basedir: baseDir }); this.baseDir = path.dirname(res); this.packageInfos = require(res); @@ -62,13 +62,13 @@ Plugin.prototype.normalizeResource = function(resource) { // so we will simply link to using it's URL if (parsed.protocol) { return { - "url": resource + 'url': resource }; } // This will be copied over from disk // and shipped with the book's build - return { "path": this.name+"/"+resource }; + return { 'path': this.name+'/'+resource }; }; // Return resources @@ -77,7 +77,7 @@ Plugin.prototype._getResources = function(base) { var book = this.infos[base]; // Compatibility with version 1.x.x - if (base == "website") book = book || this.infos.book; + if (base == 'website') book = book || this.infos.book; // Nothing specified, fallback to default if (!book) { @@ -85,7 +85,7 @@ Plugin.prototype._getResources = function(base) { } // Dynamic function - if(typeof book === "function") { + if(typeof book === 'function') { // Call giving it the context of our book return Q().then(book.bind(this.book)); } @@ -133,7 +133,7 @@ Plugin.prototype.isValid = function() { // Valid hooks _.each(this.infos.hooks, function(hook, hookName) { if (_.contains(Plugin.HOOKS, hookName)) return; - that.book.log.warn.ln("Hook '"+hookName+" 'used by plugin '"+that.packageInfos.name+"' has been removed or is deprecated"); + that.book.log.warn.ln('Hook ''+hookName+' 'used by plugin ''+that.packageInfos.name+'' has been removed or is deprecated'); }); return isValid; @@ -154,8 +154,8 @@ Plugin.prototype.callHook = function(name, data) { if (!hookFunc) return Q(data); - this.book.log.debug.ln("call hook", name); - if (!_.contains(Plugin.HOOKS, name)) this.book.log.warn.ln("hook '"+name+"' used by plugin '"+this.name+"' is deprecated, and will be removed in the coming versions"); + this.book.log.debug.ln('call hook', name); + if (!_.contains(Plugin.HOOKS, name)) this.book.log.warn.ln('hook ''+name+'' used by plugin ''+this.name+'' is deprecated, and will be removed in the coming versions'); return Q() .then(function() { @@ -168,7 +168,7 @@ Plugin.prototype.copyAssets = function(out, base) { var that = this; return this.getResources(base) - .get("assets") + .get('assets') .then(function(assets) { // Assets are undefined if(!assets) return false; |