Created
April 25, 2014 18:40
-
-
Save myndzi/11299120 to your computer and use it in GitHub Desktop.
Get list of files in directory matching mask, excluding directories, with Bluebird
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return Promise.promisify(fs.readdir)(config.path).filter(function (fileName) { | |
return config.mask.test(fileName); | |
}).map(function (fileName) { | |
var fullPath = path.join(config.path, fileName); | |
return Promise.promisify(fs.stat)(fullPath).tap(function (stat) { | |
stat.fullPath = fullPath; | |
stat.fileName = fileName; | |
}); | |
}).filter(function (stat) { | |
return stat.isFile(); | |
}).map(function (stat) { | |
return stat.fullPath; | |
}); |
Author
myndzi
commented
Apr 25, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment