summaryrefslogtreecommitdiffstats
path: root/lib/parse/listAssets.js
blob: a0dbbc9be30c42de2434f76a17fa9fb2492c2b78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

/**
    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();

    var summary = book.getSummary();
    var summaryFile = summary.getFile().getPath();

    var glossary = book.getGlossary();
    var glossaryFile = glossary.getFile().getPath();

    return fs.listAllFiles()
    .then(function(files) {
        return files.filterNot(function(file) {
            return (
                book.isContentFileIgnored(file) ||
                pages.has(file) ||
                file !== summaryFile ||
                file !== glossaryFile
            );
        });
    });
}

module.exports = listAssets;