summaryrefslogtreecommitdiffstats
path: root/lib/utils/fs.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils/fs.js')
-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
};