diff options
Diffstat (limited to 'lib/plugins')
-rw-r--r-- | lib/plugins/plugin.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/plugins/plugin.js b/lib/plugins/plugin.js index 4ed619c..64ae75f 100644 --- a/lib/plugins/plugin.js +++ b/lib/plugins/plugin.js @@ -3,6 +3,7 @@ var path = require('path'); var resolve = require('resolve'); var Promise = require('../utils/promise'); +var error = require('../utils/error'); var gitbook = require('../gitbook'); var registry = require('./registry'); @@ -12,7 +13,7 @@ function BookPlugin(book, pluginId) { this.id = pluginId; this.npmId = registry.npmId(pluginId); - this.baseDir; + this.root; this.packageInfos = undefined; this.content = undefined; @@ -42,7 +43,7 @@ BookPlugin.prototype.load = function() { try { var res = resolve.sync(that.npmId + '/package.json', { basedir: baseDir }); - that.baseDir = path.dirname(res); + that.root = path.dirname(res); that.packageInfos = require(res); } catch (err) { // Wait on https://github.com/substack/node-resolve/pull/81 to be merged @@ -55,7 +56,14 @@ BookPlugin.prototype.load = function() { } // Load plugin JS content - that.content = require(resolve.sync(that.npmId, { basedir: baseDir })); + try { + that.content = require(resolve.sync(that.npmId, { basedir: baseDir })); + } catch(err) { + throw new error.PluginError(err, { + plugin: that.id + }); + } + return true; }) |