Created
July 20, 2017 01:59
-
-
Save wescleymatos/725230f10ca9810d0592866b92b15195 to your computer and use it in GitHub Desktop.
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
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) => { | |
files.forEach((item) => { | |
fs.stat(item, (err, stat) => { | |
console.log(item, ' - ', stat.isFile()) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Para esse exercício seria interessante seguir essa abordagem: https://www.youtube.com/watch?v=nnsz91rhWuA