Skip to content

Instantly share code, notes, and snippets.

@wescleymatos
Created July 20, 2017 01:31
Show Gist options
  • Save wescleymatos/ca3ce7cf0ce905ebece213a7c75fbc15 to your computer and use it in GitHub Desktop.
Save wescleymatos/ca3ce7cf0ce905ebece213a7c75fbc15 to your computer and use it in GitHub Desktop.
const fs = require('fs')
const path = './'
function readdirPromise(path) {
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => {
if (err) {
reject(err);
} else {
resolve(files);
}
})
})
}
readdirPromise(path).then((files) => console.log(files))
@tuliofaria
Copy link

Certinho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment