Last active
August 2, 2017 19:53
-
-
Save sandrooliveira/47baf8b65e508889538235c2297d83e2 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') | |
function readdirPromise(path){ | |
return new Promise((resolve,reject) => { | |
fs.readdir(path,(err,dirContent) =>{ | |
err ? reject(err) : resolve(dirContent) | |
}) | |
}) | |
} | |
function printFilesInDir(content,path){ | |
fs.stat(path, (err, stat) => { | |
if (stat.isFile()) | |
console.log(content) | |
}) | |
} | |
async function listDir(path){ | |
const dirContent = await readdirPromise(path) | |
console.log("####### All content #######") | |
console.log(dirContent) | |
console.log("####### List of files #######") | |
dirContent.map((content) =>{ | |
printFilesInDir(content,path + "/" + content) | |
}) | |
} | |
listDir('./'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Certinho, recomendo também que de uma olhada nesse vídeo: https://www.youtube.com/watch?v=nnsz91rhWuA