Skip to content

Instantly share code, notes, and snippets.

@AntJanus
Created October 21, 2016 20:56
Show Gist options
  • Save AntJanus/33094b3a6244d855afd0d735ca62b30e to your computer and use it in GitHub Desktop.
Save AntJanus/33094b3a6244d855afd0d735ca62b30e to your computer and use it in GitHub Desktop.
import fs from 'fs';
import path from 'path';
import Promise from 'bluebird';
Promise.promisify(fs);
export default directoryModified(dirPath) {
return fs.readdirAsync(dirPath)
.then((fileListing) => {
return Promise.all(fileListing.map((file) => {
return fs.statAsync(path.join(dirPath, file))
.then((stats) => {
return Object.assign({}, stats, { name: file });
});
});
})
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment