diff options
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/fs.js | 17 |
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), |