diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-13 15:28:07 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-13 15:28:07 +0100 |
commit | ee3faaad1106bb773078e580c9c1611c8f31607c (patch) | |
tree | 5a6298dd565290e1776caec97f5ee9f42c65dd51 /lib/output/folder.js | |
parent | d2aad34935cb243dcdaeabfc28dce150c68f6340 (diff) | |
download | gitbook-ee3faaad1106bb773078e580c9c1611c8f31607c.zip gitbook-ee3faaad1106bb773078e580c9c1611c8f31607c.tar.gz gitbook-ee3faaad1106bb773078e580c9c1611c8f31607c.tar.bz2 |
Complete assets inliner
Diffstat (limited to 'lib/output/folder.js')
-rw-r--r-- | lib/output/folder.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/output/folder.js b/lib/output/folder.js index 8b899f6..90a3351 100644 --- a/lib/output/folder.js +++ b/lib/output/folder.js @@ -43,6 +43,13 @@ FolderOutput.prototype.resolve = function(filename) { return pathUtil.resolveInRoot.apply(null, [this.root()].concat(_.toArray(arguments))); }; +// Resolve a file path from a page (in the output folder) +FolderOutput.prototype.resolveForPage = function(page, filename) { + var abs = page.resolveLocal(filename); + return this.resolve(abs); +}; + + // Copy a file to the output FolderOutput.prototype.copyFile = function(from, to) { var that = this; @@ -88,12 +95,20 @@ FolderOutput.prototype.hasFile = function(filename) { // Create a new unique file // Returns its filename FolderOutput.prototype.createNewFile = function(base, filename) { + var that = this; + if (!filename) { filename = path.basename(filename); base = path.dirname(base); } - return fs.uniqueFilename(this.resolve(base), filename); + return fs.uniqueFilename(this.resolve(base), filename) + .then(function(out) { + out = path.join(base, out); + + return fs.ensure(that.resolve(out)) + .thenResolve(out); + }); }; |