diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-22 11:00:21 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-22 11:00:21 +0200 |
commit | 4336fdb2414d460ffee68a0cc87c0cb0c85cf56e (patch) | |
tree | 279f711ab98666c892c19a7b9e4073a094f03f98 /lib/plugins/findForBook.js | |
parent | 87db7cf1d412fa6fbd18e9a7e4f4755f2c0c5547 (diff) | |
download | gitbook-4336fdb2414d460ffee68a0cc87c0cb0c85cf56e.zip gitbook-4336fdb2414d460ffee68a0cc87c0cb0c85cf56e.tar.gz gitbook-4336fdb2414d460ffee68a0cc87c0cb0c85cf56e.tar.bz2 |
Base
Diffstat (limited to 'lib/plugins/findForBook.js')
-rw-r--r-- | lib/plugins/findForBook.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/plugins/findForBook.js b/lib/plugins/findForBook.js new file mode 100644 index 0000000..75a4988 --- /dev/null +++ b/lib/plugins/findForBook.js @@ -0,0 +1,27 @@ +var path = require('path'); +var Immutable = require('immutable'); + +var Promise = require('../utils/promise'); +var findInstalled = require('./findInstalled'); + +/** + List all plugins installed in a book + + @param {Book} + @return {Promise<OrderedMap<String:Plugin>>} +*/ +function findForBook(book) { + return Promise.all([ + findInstalled(path.resolve(__dirname, '../..')), + findInstalled(book.getRoot()) + ]) + .then(function(results) { + return Immutable.List(results) + .reduce(function(out, result) { + return out.merge(result); + }, Immutable.OrderedMap()); + }); +} + + +module.exports = findForBook; |