summaryrefslogtreecommitdiffstats
path: root/lib/utils
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-13 15:28:07 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-13 15:28:07 +0100
commitee3faaad1106bb773078e580c9c1611c8f31607c (patch)
tree5a6298dd565290e1776caec97f5ee9f42c65dd51 /lib/utils
parentd2aad34935cb243dcdaeabfc28dce150c68f6340 (diff)
downloadgitbook-ee3faaad1106bb773078e580c9c1611c8f31607c.zip
gitbook-ee3faaad1106bb773078e580c9c1611c8f31607c.tar.gz
gitbook-ee3faaad1106bb773078e580c9c1611c8f31607c.tar.bz2
Complete assets inliner
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/fs.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/utils/fs.js b/lib/utils/fs.js
index 3f1c11f..c0ff0c9 100644
--- a/lib/utils/fs.js
+++ b/lib/utils/fs.js
@@ -83,6 +83,12 @@ function uniqueFilename(base, filename) {
return Promise(path.relative(base, _filename));
}
+// Create all required folder to create a file
+function ensureFile(filename) {
+ var base = path.dirname(filename);
+ return Promise.nfcall(mkdirp, base);
+}
+
module.exports = {
exists: fileExists,
existsSync: fs.existsSync,
@@ -96,5 +102,6 @@ module.exports = {
copy: copyFile,
tmpFile: genTmpFile,
download: download,
- uniqueFilename: uniqueFilename
+ uniqueFilename: uniqueFilename,
+ ensure: ensureFile
};