diff options
Diffstat (limited to 'lib/utils/fs.js')
-rw-r--r-- | lib/utils/fs.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/utils/fs.js b/lib/utils/fs.js index 716e3a0..b82701f 100644 --- a/lib/utils/fs.js +++ b/lib/utils/fs.js @@ -30,6 +30,7 @@ var fsUtils = { fs.exists(path, d.resolve); return d.promise; }, + findFile: findFile, existsSync: fs.existsSync.bind(fs), readFileSync: fs.readFileSync.bind(fs), clean: cleanFolder, @@ -178,4 +179,15 @@ function cleanFolder(root) { }); } +// Find a file in a folder (case incensitive) +// Return the real filename +function findFile(root, filename) { + return Q.nfcall(fs.readdir, root) + .then(function(files) { + return _.find(files, function(file) { + return (file.toLowerCase() == filename.toLowerCase()); + }); + }); +} + module.exports = fsUtils; |