summaryrefslogtreecommitdiffstats
path: root/lib/utils/fs.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-04-29 16:50:50 +0200
committerSamy Pessé <samypesse@gmail.com>2016-04-29 16:50:50 +0200
commit98f70879bde88d32e898ff057f4dc7ceaff7e25e (patch)
tree557e0948683cd985fdcc50519f693ca07a2a972c /lib/utils/fs.js
parentceb4627f4e700b0e8058fae6760dbf9bb2ca7333 (diff)
downloadgitbook-98f70879bde88d32e898ff057f4dc7ceaff7e25e.zip
gitbook-98f70879bde88d32e898ff057f4dc7ceaff7e25e.tar.gz
gitbook-98f70879bde88d32e898ff057f4dc7ceaff7e25e.tar.bz2
Complete ebook generation using ebook-convert
Diffstat (limited to 'lib/utils/fs.js')
-rw-r--r--lib/utils/fs.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/utils/fs.js b/lib/utils/fs.js
index be3ec0e..3f97096 100644
--- a/lib/utils/fs.js
+++ b/lib/utils/fs.js
@@ -113,6 +113,22 @@ function assertFile(filePath, generator) {
});
}
+/**
+ Pick a file, returns the absolute path if exists, undefined otherwise
+
+ @param {String} rootFolder
+ @param {String} fileName
+ @return {String}
+*/
+function pickFile(rootFolder, fileName) {
+ var result = path.join(rootFolder, fileName);
+ if (fs.existsSync(result)) {
+ return result;
+ }
+
+ return undefined;
+}
+
module.exports = {
exists: fileExists,
existsSync: fs.existsSync,
@@ -120,6 +136,7 @@ module.exports = {
readFile: Promise.nfbind(fs.readFile),
writeFile: Promise.nfbind(fs.writeFile),
assertFile: assertFile,
+ pickFile: pickFile,
stat: Promise.nfbind(fs.stat),
statSync: fs.statSync,
readdir: Promise.nfbind(fs.readdir),