(startPath, filter)
| 74 | } |
| 75 | |
| 76 | export function findFile(startPath, filter) { |
| 77 | if (!fs.existsSync(startPath)) { |
| 78 | return null; |
| 79 | } |
| 80 | const files = fs.readdirSync(startPath); |
| 81 | for (const file of files) { |
| 82 | const filename = path.join(startPath, file); |
| 83 | const stat = fs.lstatSync(filename); |
| 84 | if (stat.isDirectory()) { |
| 85 | const result = findFile(filename, filter); |
| 86 | if (result) return result; |
| 87 | } else if (filter(file)) { |
| 88 | return filename; |
| 89 | } |
| 90 | } |
| 91 | return null; |
| 92 | } |
| 93 | |
| 94 | export function fileExists(filePath) { |
| 95 | return fs.existsSync(filePath); |
no test coverage detected