Skip to content

Instantly share code, notes, and snippets.

@eugenserbanescu
Created July 18, 2018 13:16
Show Gist options
  • Save eugenserbanescu/64377a5074637cca2b7f7e7194ace957 to your computer and use it in GitHub Desktop.
Save eugenserbanescu/64377a5074637cca2b7f7e7194ace957 to your computer and use it in GitHub Desktop.
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