Last active
May 4, 2018 17:05
-
-
Save krutoo/083baf69bccc4fe29e8197ea2107ed23 to your computer and use it in GitHub Desktop.
Node.js readdirRecuriveSync
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
import fs from 'fs'; | |
import path from 'path'; | |
export function readdirRecuriveSync(dir, filelist) { | |
filelist = filelist || []; | |
var files = fs.readdirSync(dir); | |
files.forEach(function (file) { | |
file = path.join(dir, file); | |
if (fs.statSync(file).isDirectory()) { | |
filelist = readdirRecuriveSync(file, filelist); | |
} else { | |
filelist.push(file); | |
} | |
}); | |
return filelist; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment