diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-04-27 12:08:00 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-04-27 12:08:00 +0200 |
commit | 4ca23b84a4ce5c7c03c72b0cb78357aaff1be27c (patch) | |
tree | 5966848cb10275d5aa93c4df2b1f208fd54ddb05 /lib/output/helper/writeFile.js | |
parent | b05eb8440b59db6d39ae06712ddda5651786e00a (diff) | |
download | gitbook-4ca23b84a4ce5c7c03c72b0cb78357aaff1be27c.zip gitbook-4ca23b84a4ce5c7c03c72b0cb78357aaff1be27c.tar.gz gitbook-4ca23b84a4ce5c7c03c72b0cb78357aaff1be27c.tar.bz2 |
Fix filters for theme templates
Diffstat (limited to 'lib/output/helper/writeFile.js')
-rw-r--r-- | lib/output/helper/writeFile.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/output/helper/writeFile.js b/lib/output/helper/writeFile.js new file mode 100644 index 0000000..3e2261d --- /dev/null +++ b/lib/output/helper/writeFile.js @@ -0,0 +1,23 @@ +var path = require('path'); +var fs = require('../../utils/fs'); + +/** + Write a file to the output folder + + @param {Output} output + @param {String} filePath + @param {Buffer|String} content + @return {Promise} +*/ +function writeFile(output, filePath, content) { + var rootFolder = output.getRoot(); + filePath = path.join(rootFolder, filePath); + + return fs.ensure(filePath) + .then(function() { + return fs.writeFile(filePath, content); + }) + .thenResolve(output); +} + +module.exports = writeFile; |