(startPath, filter)
| 85 | } |
| 86 | |
| 87 | export function findFile(startPath, filter) { |
| 88 | if (!fs.existsSync(startPath)) { |
| 89 | return null; |
| 90 | } |
| 91 | const files = fs.readdirSync(startPath); |
| 92 | for (const file of files) { |
| 93 | const filename = path.join(startPath, file); |
| 94 | const stat = fs.lstatSync(filename); |
| 95 | if (stat.isDirectory()) { |
| 96 | const result = findFile(filename, filter); |
| 97 | if (result) return result; |
| 98 | } else if (filter(file)) { |
| 99 | return filename; |
| 100 | } |
| 101 | } |
| 102 | return null; |
| 103 | } |
| 104 | |
| 105 | export function fileExists(filePath) { |
| 106 | return fs.existsSync(filePath); |
no test coverage detected