Skip to content

Instantly share code, notes, and snippets.

@tejasrr19
Created April 10, 2017 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tejasrr19/0a7448fe3a238d8a4946cf90af558317 to your computer and use it in GitHub Desktop.
Save tejasrr19/0a7448fe3a238d8a4946cf90af558317 to your computer and use it in GitHub Desktop.
List all Files in a Directory including files in Subdirectories.
const allRoutes = ((routeDir, routes) => {
const routeFiles = fs.readdirSync(routeDir);
routes = routes || [];
routeFiles.forEach((file) => {
if(fs.statSync(routeDir + file).isDirectory()) {
routes = allRoutes(routeDir + file + '/', routes);
} else {
routes.push(file);
}
});
return routes;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment