(inputPath: string)
| 44 | * @throws FileResolutionError if the path doesn't exist |
| 45 | */ |
| 46 | export async function resolvePath(inputPath: string): Promise<ResolvedPath> { |
| 47 | const cwd = process.cwd() |
| 48 | const absolutePath = resolve(cwd, inputPath) |
| 49 | |
| 50 | let fileStat: import('node:fs').Stats |
| 51 | try { |
| 52 | fileStat = await stat(absolutePath) |
| 53 | } catch (err: unknown) { |
| 54 | const code = (err as NodeJS.ErrnoException | undefined)?.code |
| 55 | if (code === 'ENOENT' || code === 'ENOTDIR') { |
| 56 | throw new FileResolutionError(`File or directory not found: ${inputPath}`) |
| 57 | } |
| 58 | throw err // Rethrow permission errors (EACCES), etc. |
| 59 | } |
| 60 | |
| 61 | const isDirectory = fileStat.isDirectory() |
| 62 | const extension = isDirectory ? '' : extname(absolutePath).toLowerCase() |
| 63 | |
| 64 | return { absolutePath, stat: fileStat, isDirectory, extension } |
| 65 | } |
| 66 | |
| 67 | export interface ResolveDeepnoteFileOptions { |
| 68 | /** Custom error message when no .deepnote files are found */ |
no outgoing calls
no test coverage detected