Created
July 18, 2018 13:16
-
-
Save eugenserbanescu/64377a5074637cca2b7f7e7194ace957 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
function getFilesInDirSync(pathToDir, files = []) { | |
const dirContents = fs.readdirSync(pathToDir); | |
return files.concat(dirContents.map(item => { | |
const isDir = fs.statSync(pathToDir + item).isDirectory() | |
return isDir ? getFilesInDirSync(`${pathToDir}/{item}`, files) : [`${pathToDir}/{item}`] | |
})) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment