diff options
author | Johan Preynat <johan.preynat@gmail.com> | 2016-10-01 21:49:06 +0200 |
---|---|---|
committer | Johan Preynat <johan.preynat@gmail.com> | 2016-10-01 21:49:06 +0200 |
commit | 32183b6650e0a3ff963b6bb8d4a4dd1d10186818 (patch) | |
tree | a0ae209829767179a096638337235075b5cb4c43 | |
parent | 33ff60cee7121dea2c172a2857cba411b01abe3b (diff) | |
parent | cb3d6a7f0192f6b67e8cbf22dcf4576ff8c85a70 (diff) | |
download | gitbook-32183b6650e0a3ff963b6bb8d4a4dd1d10186818.zip gitbook-32183b6650e0a3ff963b6bb8d4a4dd1d10186818.tar.gz gitbook-32183b6650e0a3ff963b6bb8d4a4dd1d10186818.tar.bz2 |
Merge branch 'fix-3.1-version'
-rw-r--r-- | lib/parse/parsePageFromString.js | 1 | ||||
-rw-r--r-- | lib/parse/parsePagesList.js | 31 |
2 files changed, 26 insertions, 6 deletions
diff --git a/lib/parse/parsePageFromString.js b/lib/parse/parsePageFromString.js index 80c147b..e64664b 100644 --- a/lib/parse/parsePageFromString.js +++ b/lib/parse/parsePageFromString.js @@ -9,6 +9,7 @@ var direction = require('direction'); * @return {Page} */ function parsePageFromString(page, content) { + // Parse page YAML var parsed = fm(content); return page.merge({ diff --git a/lib/parse/parsePagesList.js b/lib/parse/parsePagesList.js index 1cf42f5..fa15a9d 100644 --- a/lib/parse/parsePagesList.js +++ b/lib/parse/parsePagesList.js @@ -11,15 +11,26 @@ var parsePage = require('./parsePage'); @param {Book} book @param {String} filePath - @return {Page} + @return {Page?} */ function parseFilePage(book, filePath) { var fs = book.getContentFS(); return fs.statFile(filePath) - .then(function(file) { - var page = Page.createForFile(file); - return parsePage(book, page); + .then( + function(file) { + var page = Page.createForFile(file); + return parsePage(book, page); + }, + function(err) { + // file doesn't exist + return null; + } + ) + .fail(function(err) { + var logger = book.getLogger(); + logger.error.ln('error while parsing page "' + filePath + '":'); + throw err; }); } @@ -48,9 +59,12 @@ function parsePagesList(book) { return parseFilePage(book, filepath) .then(function(page) { - map = map.set(filepath, page); - }, function() { // file doesn't exist + if (!page) { + return; + } + + map = map.set(filepath, page); }); }) ) @@ -65,6 +79,11 @@ function parsePagesList(book) { return parseFilePage(book, file.getPath()) .then(function(page) { + // file doesn't exist + if (!page) { + return; + } + map = map.set(file.getPath(), page); }); }) |