Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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}`]
- }))
- })
Add Comment
Please, Sign In to add comment