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.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/output/folder.js b/lib/output/folder.js
index aabdcc4..8b899f6 100644
--- a/lib/output/folder.js
+++ b/lib/output/folder.js
@@ -34,7 +34,7 @@ FolderOutput.prototype.prepare = function() {
// ----- Utility methods -----
// Return path to the root folder
-FolderOutput.prototype.root = function(filename) {
+FolderOutput.prototype.root = function() {
return path.resolve(process.cwd(), this.book.config.get('output'));
};
@@ -74,10 +74,26 @@ FolderOutput.prototype.writeFile = function(filename, buf) {
});
};
+// Return true if a file exists in the output folder
+FolderOutput.prototype.hasFile = function(filename) {
+ var that = this;
+
+ return Promise()
+ .then(function() {
+ return fs.exists(that.resolve(filename));
+ });
+};
+
+
// Create a new unique file
// Returns its filename
FolderOutput.prototype.createNewFile = function(base, filename) {
+ if (!filename) {
+ filename = path.basename(filename);
+ base = path.dirname(base);
+ }
+ return fs.uniqueFilename(this.resolve(base), filename);
};