summaryrefslogtreecommitdiffstats
path: root/lib/output/folder.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output/folder.js')
-rw-r--r--lib/output/folder.js27
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())
+ ]);
+ });
};