diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-29 17:46:59 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-29 17:46:59 +0200 |
commit | 0229272b0a1a1e7e739d45f1c3650b5092d96bd4 (patch) | |
tree | af0f4f1dd26d759a6d3e06dd482ac1893057f5f8 /lib/api | |
parent | c817acff098a538e8e4cdcdeded45a2c35890fe3 (diff) | |
download | gitbook-0229272b0a1a1e7e739d45f1c3650b5092d96bd4.zip gitbook-0229272b0a1a1e7e739d45f1c3650b5092d96bd4.tar.gz gitbook-0229272b0a1a1e7e739d45f1c3650b5092d96bd4.tar.bz2 |
Add api this.readFile and this.readFileAsString
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/encodeGlobal.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/api/encodeGlobal.js b/lib/api/encodeGlobal.js index 0191c50..d66fd69 100644 --- a/lib/api/encodeGlobal.js +++ b/lib/api/encodeGlobal.js @@ -16,6 +16,7 @@ var fileToURL = require('../output/helper/fileToURL'); */ function encodeGlobal(output) { var book = output.getBook(); + var fs = book.getContentFS(); var logger = output.getLogger(); var outputFolder = output.getRoot(); @@ -35,6 +36,26 @@ function encodeGlobal(output) { return book.isLanguageBook(); }, '"isSubBook" is deprecated, use "isLanguageBook()" instead'), + /** + Read a file from the book + + @param {String} fileName + @return {Promise<Buffer>} + */ + readFile: function(fileName) { + return fs.read(fileName); + }, + + /** + Read a file from the book as a string + + @param {String} fileName + @return {Promise<String>} + */ + readFileAsString: function(fileName) { + return fs.readAsString(fileName); + }, + output: { /** Name of the generator being used |