Skip to content

Instantly share code, notes, and snippets.

@caioregatieri
Created July 20, 2017 00:03
Show Gist options
  • Save caioregatieri/a6fb6677dcfdeebbacffc3cd0a1855bb to your computer and use it in GitHub Desktop.
Save caioregatieri/a6fb6677dcfdeebbacffc3cd0a1855bb to your computer and use it in GitHub Desktop.
function readDirPromise(path) {
const fs = require('fs')
return new Promise((resolve, reject) => {
fs.readdir(path, (err, files) => {
if (err) {
reject(err)
} else {
resolve(files)
}
})
})
}
async function showFileOnDir(path) {
try {
const content = await readDirPromise(path)
console.log('content', content)
} catch (e) {
console.log(e)
}
}
showFileOnDir('./');
@tuliofaria
Copy link

Certinho

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