diff options
Diffstat (limited to 'lib/generate')
-rw-r--r-- | lib/generate/plugin.js | 16 | ||||
-rw-r--r-- | lib/generate/site/index.js | 9 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js index 77bbee5..d1becd4 100644 --- a/lib/generate/plugin.js +++ b/lib/generate/plugin.js @@ -2,7 +2,6 @@ var _ = require("lodash"); var Q = require("q"); var semver = require("semver"); var path = require("path"); -var crc = require('crc'); var fs = require("./fs"); var pkg = require("../../package.json"); @@ -44,8 +43,7 @@ Plugin.prototype.getResources = function(resource) { return _.chain(this.infos.book[resource]) .map(function(resource) { return { - "path": this.resolveFile(resource), - "id": crc.hex32(crc.crc32(resource)) + "path": this.name+"/"+resource } }.bind(this)) .value(); @@ -80,6 +78,18 @@ Plugin.prototype.callHook = function(name, args) { }); }; +// Copy plugin assets fodler +Plugin.prototype.copyAssets = function(out) { + if (!this.infos.book || !this.infos.book.assets) return Q(); + return fs.copy( + this.resolveFile(this.infos.book.assets), + out + ); +}; + + + + // Normalize a list of plugin name to use Plugin.normalizeNames = function(names) { // Normalize list to an array diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index eaba6ee..809a7fc 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -159,13 +159,8 @@ Generator.prototype.copyAssets = function() { // Copy plugins assets .then(function() { return Q.all( - _.map(that.plugins.resources, function(resources, resourceType) { - return Q.all(_.map(resources, function(resource) { - return fs.copy( - resource.path, - path.join(that.options.output, "gitbook/plugins/", resource.id+"."+resourceType) - ); - })); + _.map(that.plugins.list, function(plugin) { + return plugin.copyAssets(path.join(that.options.output, "gitbook/plugins/", plugin.name)) }) ); }) |