Created
July 21, 2017 01:30
-
-
Save nathabonfim59/58ffbad0941779d6cd3c83d6e64531d1 to your computer and use it in GitHub Desktop.
FullStackAcademy - aula 1 - exercício 3
This file contains 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 = './' | |
/** | |
* Lê um diretório e retorna em array com os nomes de arquivos e pastas encontrados nele | |
* @param {string} path Diretório a ser analisado | |
*/ | |
const readdirPromise = function(path) { | |
return new Promise((resolve, reject) => | |
fs.readdir(path, (err, arquivos) => { | |
if (err) { | |
reject(err) | |
} else { | |
resolve(arquivos) | |
} | |
}) | |
)} | |
readdirPromise(path).then((files)=> console.log(files)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Certinho.