Skip to content

Instantly share code, notes, and snippets.

@bel0v
Last active December 22, 2020 22:10
Show Gist options
  • Save bel0v/954f689e91ab030d34249ce04c4754b8 to your computer and use it in GitHub Desktop.
Save bel0v/954f689e91ab030d34249ce04c4754b8 to your computer and use it in GitHub Desktop.
Get all files in directory and subdirectories recursively
function recursiveRead(dir) {
return fs.readdirSync(dir).flatMap((file) => {
const absoluteDir = path.join(dir, file);
if (fs.statSync(absoluteDir).isDirectory())
return recursiveRead(absoluteDir);
else return absoluteDir;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment