diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-17 13:30:45 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-17 13:30:45 +0100 |
commit | 853ba6079c37aa747721c8ee5d014479e69f3ad9 (patch) | |
tree | 60f655c942bafdc3e2caa6867b62a2173708a30f /lib/output/folder.js | |
parent | b6104c64fecb72c9f40554600d456c27dbd18be8 (diff) | |
download | gitbook-853ba6079c37aa747721c8ee5d014479e69f3ad9.zip gitbook-853ba6079c37aa747721c8ee5d014479e69f3ad9.tar.gz gitbook-853ba6079c37aa747721c8ee5d014479e69f3ad9.tar.bz2 |
Correctly clean and ignore output folder
Diffstat (limited to 'lib/output/folder.js')
-rw-r--r-- | lib/output/folder.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/output/folder.js b/lib/output/folder.js index 9964ecd..05843cd 100644 --- a/lib/output/folder.js +++ b/lib/output/folder.js @@ -30,7 +30,32 @@ module.exports = function folderOutput(Base) { // Prepare the generation by creating the output folder FolderOutput.prototype.prepare = function() { - return fs.mkdirp(this.root()); + var that = this; + + return Promise() + .then(function() { + return Base.prototype.prepare.apply(that); + }) + + // Cleanup output folder + .then(function() { + return fs.rmDir(that.root()) + .fail(function() { + return Promise(); + }); + }) + + // Create output folder + .then(function() { + return fs.mkdirp(that.root()); + }) + + // Add output folder to ignored files + .then(function() { + that.ignore.addPattern([ + path.relative(that.book.root, that.root()) + ]); + }); }; |