Advertisement
AbdulMuttaqin

recursive files

Jul 26th, 2021
1,766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function includeRouter(folderName) {
  3.     fs.readdirSync(folderName).forEach(function(file) {
  4.  
  5.         var fullName = path.join(folderName, file);
  6.         var stat = fs.lstatSync(fullName);
  7.  
  8.         if (stat.isDirectory()) {
  9.           includeRouter(fullName);
  10.         } else if (file.toLowerCase().indexOf('.js')) {
  11.             require('./' + fullName)(app);
  12.             console.log("require('" + fullName + "')");
  13.         }
  14.     });
  15. }
  16. includeRouter('router');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement