Skip to content

Instantly share code, notes, and snippets.

@jeyziel
Created July 20, 2017 18:12
Show Gist options
  • Save jeyziel/850df115a5277c5b138c662ae270ebaf to your computer and use it in GitHub Desktop.
Save jeyziel/850df115a5277c5b138c662ae270ebaf to your computer and use it in GitHub Desktop.
const fs = require('fs')
const path = './'
const readdirPromise = (path) => {
return new Promise( ( resolve, reject ) => {
fs.readdir( path, ( err, files) => {
if ( err ) {
reject( err )
}else {
resolve ( files )
}
})
})
}
const getFileAndDir = async (path) => {
const files = await readdirPromise(path)
console.log(files);
}
getFileAndDir(path);
@tuliofaria
Copy link

Certinho.

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