diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-01-28 23:42:00 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-01-28 23:42:00 +0100 |
commit | e83d63c2aa5e30c26ada888990b263e6b786d3f6 (patch) | |
tree | af460422630bfbaa9016c51d5ec384fa3923d01d /lib/output.js | |
parent | ff30ba62ba694658d1575b0cf3a0fbf3d5e00d62 (diff) | |
download | gitbook-e83d63c2aa5e30c26ada888990b263e6b786d3f6.zip gitbook-e83d63c2aa5e30c26ada888990b263e6b786d3f6.tar.gz gitbook-e83d63c2aa5e30c26ada888990b263e6b786d3f6.tar.bz2 |
Index page of summary when parsing
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/output.js b/lib/output.js index c22e8de..89233da 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1,6 +1,9 @@ +var _ = require('lodash'); +var fs = require('fs'); var Ignore = require('ignore'); var Promise = require('./utils/promise'); +var pathUtil = require('./utils/path'); var generators = require('./generators'); var PluginsManager = require('./plugins'); @@ -24,9 +27,16 @@ function Output(book, type) { ]); } -// Write a file to the output folder -Output.prototype.writeFile = function(filename, buf) { +// Resolve a file in the output directory +Output.prototype.resolve = function(filename) { + return pathUtil.resolveInRoot.apply(null, [this.book.config.get('output')].concat(_.toArray(arguments))); +}; + +// Write a file/buffer to the output folder +Output.prototype.writeFile = function(filename, buf) { + filename = this.resolve(filename); + return Promise.nfcall(fs.writeFileSync, filename, buf); }; // Start the generation, for a parsed book |