Skip to content

Instantly share code, notes, and snippets.

@bengsiswantoh
Last active July 17, 2020 03:25
Show Gist options
  • Save bengsiswantoh/322794b92d1051833a51b108981f6eb9 to your computer and use it in GitHub Desktop.
Save bengsiswantoh/322794b92d1051833a51b108981f6eb9 to your computer and use it in GitHub Desktop.
const fs = require("fs")
const path = require("path")
const getAllFiles = function(dirPath, arrayOfFiles) {
files = fs.readdirSync(dirPath)
arrayOfFiles = arrayOfFiles || []
files.forEach(function(file) {
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles)
} else {
arrayOfFiles.push(path.join(__dirname, dirPath, "/", file))
}
})
return arrayOfFiles
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment