Created
July 19, 2017 20:51
-
-
Save diogomascarenha/3c550e793d157d0e3f4ee20f5863107e to your computer and use it in GitHub Desktop.
DevPleno - FullstackAcademy - Exercício 03
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
| var fs = require('fs') | |
| var Promise = require('promise') | |
| const path = './' | |
| function readdirPromise(path){ | |
| return new Promise(function(fulfill, reject){ | |
| fs.readdir(path, (err, files) => { | |
| if(err){ | |
| reject(err) | |
| }else{ | |
| fulfill(files) | |
| } | |
| }) | |
| }) | |
| } | |
| readdirPromise(path).then(function(files){ | |
| console.log(files) | |
| }).catch(function(err){ | |
| console.log(err) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Certinho