( filePath: string )
| 50 | * Reads stat metadata while distinguishing absent paths from inspection errors. |
| 51 | */ |
| 52 | export async function statIfExists( |
| 53 | filePath: string |
| 54 | ): Promise<MaybeStatsResult> { |
| 55 | try { |
| 56 | return { stats: await stat(filePath) }; |
| 57 | } catch (error) { |
| 58 | if (isMissingPathError(error)) { |
| 59 | return { missing: true }; |
| 60 | } |
| 61 | |
| 62 | return { reason: `could not inspect: ${getErrorMessage(error)}` }; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Returns whether a resolved executable should be invoked through Node. |
no test coverage detected