Created
April 10, 2017 17:21
-
-
Save tejasrr19/0a7448fe3a238d8a4946cf90af558317 to your computer and use it in GitHub Desktop.
List all Files in a Directory including files in Subdirectories.
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
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