Skip to content

Instantly share code, notes, and snippets.

@hariadi
Created June 19, 2013 08:27
Show Gist options
  • Save hariadi/5812621 to your computer and use it in GitHub Desktop.
Save hariadi/5812621 to your computer and use it in GitHub Desktop.
just to save
fs = require('fs');
function getDirectoryFiles(directory, callback) {
fs.readdir(directory, function(err, files) {
files.forEach(function(file){
fs.stat(directory + '/' + file, function(err, stats) {
if(stats.isFile()) {
callback(directory + '/' + file);
}
if(stats.isDirectory()) {
getDirectoryFiles(directory + '/' + file, callback);
}
});
});
});
}
getDirectoryFiles('.', function(file_with_path) {
console.log(file_with_path);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment