Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. const fs = require('fs');
  2.  
  3. function autoload(route_path, app) {
  4. fs.readdirSync(route_path).forEach(function(file) {
  5. var filepath = route_path + '/' + file;
  6. fs.stat(filepath, function(err,stat) {
  7. if (stat.isDirectory()) {
  8. autoload(filepath, app);
  9. } else {
  10. require(filepath)(app);
  11. }
  12. });
  13. });
  14. }
  15.  
  16. module.exports = autoload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement