MCPcopy Index your code
hub / github.com/deepnote/deepnote / resolvePath

Function resolvePath

packages/cli/src/utils/file-resolver.ts:46–65  ·  view source on GitHub ↗
(inputPath: string)

Source from the content-addressed store, hash-verified

44 * @throws FileResolutionError if the path doesn't exist
45 */
46export 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
67export interface ResolveDeepnoteFileOptions {
68 /** Custom error message when no .deepnote files are found */

Callers 2

convertFileFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected