Parse ignore files @param {Book} @return {Book}
(book)
| 25 | @return {Book} |
| 26 | */ |
| 27 | function parseIgnore(book) { |
| 28 | if (book.isLanguageBook()) { |
| 29 | return Promise.reject(new Error('Ignore files could be parsed for language books')); |
| 30 | } |
| 31 | |
| 32 | var fs = book.getFS(); |
| 33 | var ignore = book.getIgnore(); |
| 34 | |
| 35 | ignore = ignore.add(DEFAULT_IGNORES); |
| 36 | |
| 37 | return Promise.serie(IGNORE_FILES, function(filename) { |
| 38 | return fs.readAsString(filename) |
| 39 | .then(function(content) { |
| 40 | ignore = ignore.add(content.toString().split(/\r?\n/)); |
| 41 | }, function(err) { |
| 42 | return Promise(); |
| 43 | }); |
| 44 | }) |
| 45 | |
| 46 | .then(function() { |
| 47 | return book.setIgnore(ignore); |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | module.exports = parseIgnore; |