summaryrefslogtreecommitdiffstats
path: root/lib/output/folder.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-13 15:04:18 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-13 15:04:18 +0100
commitd2aad34935cb243dcdaeabfc28dce150c68f6340 (patch)
treee681361847e64762935465c1fbc81e9a9d72d122 /lib/output/folder.js
parentd8ed34beba05bde85af420cc4e42a065021653dc (diff)
downloadgitbook-d2aad34935cb243dcdaeabfc28dce150c68f6340.zip
gitbook-d2aad34935cb243dcdaeabfc28dce150c68f6340.tar.gz
gitbook-d2aad34935cb243dcdaeabfc28dce150c68f6340.tar.bz2
Improve performance of svg conversion
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);
};