(dirPath: string)
| 86 | * List entries in a directory. Returns empty array if directory doesn't exist. |
| 87 | */ |
| 88 | export async function readDir(dirPath: string): Promise<string[]> { |
| 89 | try { |
| 90 | return await fs.readdir(dirPath); |
| 91 | } catch (error) { |
| 92 | const code = (error as NodeJS.ErrnoException)?.code; |
| 93 | if (code === 'ENOENT' || code === 'ENOTDIR') { |
| 94 | return []; |
| 95 | } |
| 96 | |
| 97 | throw error; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Returns true when an error means the path was simply not found. ENOENT is |
no outgoing calls
no test coverage detected