Created
September 15, 2017 08:32
-
-
Save schipiga/a48bbea439c5cf439147ee1d6b85293b to your computer and use it in GitHub Desktop.
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
"use strict" | |
var fs = require("fs"); | |
var path = require("path"); | |
var traversal = root => { | |
var files = []; | |
var folders = [root]; | |
while (folders.length != 0) { | |
var folder = folders.shift(); | |
var fileNames = fs.readdirSync(folder); | |
for (var fileName of fileNames) { | |
var filePath = path.resolve(folder, fileName); | |
if (fs.statSync(filePath).isDirectory()) { | |
folders.push(filePath); | |
} else { | |
files.push(filePath); | |
}; | |
}; | |
}; | |
return files; | |
}; | |
var main = module.exports.main = () => traversal(process.cwd()); | |
if (require.main === module) main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment