| 63 | } |
| 64 | |
| 65 | function fromDir(startPath: any, filter: any, callback: any) { |
| 66 | |
| 67 | if (!fs.existsSync(startPath)) { |
| 68 | console.log("no dir ", startPath); |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | var files = fs.readdirSync(startPath); |
| 73 | for (var i = 0; i < files.length; i++) { |
| 74 | var filename = path.join(startPath, files[i]); |
| 75 | var stat = fs.lstatSync(filename); |
| 76 | if (stat.isDirectory() && filename.startsWith('node_modules') === false && filename.startsWith('.next') === false) { |
| 77 | fromDir(filename, filter, callback); //recurse |
| 78 | } else if (filename.endsWith(filter)) { |
| 79 | callback(filename); |
| 80 | }; |
| 81 | }; |
| 82 | }; |
| 83 | |
| 84 | |
| 85 | build(); |