diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-22 22:21:34 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-22 22:21:34 +0200 |
commit | fb0ea4610d7835a14c91fd57268ae3d809062f8d (patch) | |
tree | 2755a24a10fd30b5f919476eed4fa20a18e440be /lib/parse | |
parent | 4f86a9978b4b27b12e40ab0b5b9e18b8e0615266 (diff) | |
download | gitbook-fb0ea4610d7835a14c91fd57268ae3d809062f8d.zip gitbook-fb0ea4610d7835a14c91fd57268ae3d809062f8d.tar.gz gitbook-fb0ea4610d7835a14c91fd57268ae3d809062f8d.tar.bz2 |
Add base utils for generation
Diffstat (limited to 'lib/parse')
-rw-r--r-- | lib/parse/index.js | 3 | ||||
-rw-r--r-- | lib/parse/listAssets.js | 24 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/parse/index.js b/lib/parse/index.js index 042024b..58561fb 100644 --- a/lib/parse/index.js +++ b/lib/parse/index.js @@ -6,5 +6,6 @@ module.exports = { parseReadme: require('./parseReadme'), parseConfig: require('./parseConfig'), parsePagesList: require('./parsePagesList'), - parseIgnore: require('./parseIgnore') + parseIgnore: require('./parseIgnore'), + listAssets: require('./listAssets') }; diff --git a/lib/parse/listAssets.js b/lib/parse/listAssets.js new file mode 100644 index 0000000..6159eda --- /dev/null +++ b/lib/parse/listAssets.js @@ -0,0 +1,24 @@ + +/** + List all assets in a book + Assets are file not ignored and not a page + + @param {Book} book + @param {List<String>} pages + @param +*/ +function listAssets(book, pages) { + var fs = book.getContentFS(); + + return fs.listAllFiles() + .then(function(files) { + return files.filterNot(function(file) { + return ( + book.isContentFileIgnored(file) || + pages.has(file) + ); + }); + }); +} + +module.exports = listAssets; |