MCPcopy
hub / github.com/deepnote/deepnote / createValidateAction

Function createValidateAction

packages/cli/src/commands/validate.ts:40–65  ·  view source on GitHub ↗
(
  _program: Command
)

Source from the content-addressed store, hash-verified

38}
39
40export function createValidateAction(
41 _program: Command
42): (path: string | undefined, options: ValidateOptions) => Promise<void> {
43 return async (path, options) => {
44 try {
45 debug(`Validating file: ${path}`)
46 debug(`Options: ${JSON.stringify(options)}`)
47 await validateDeepnoteFile(path, options)
48 } catch (error) {
49 // If validation was already handled (output already produced), just exit
50 if (error instanceof ValidationHandledError) {
51 process.exit(error.exitCode)
52 }
53 const message = error instanceof Error ? error.message : String(error)
54 // Use InvalidUsage for file resolution and parse errors (user input), Error for runtime failures
55 const exitCode =
56 error instanceof FileResolutionError || error instanceof ParseError ? ExitCode.InvalidUsage : ExitCode.Error
57 if (options.output === 'json') {
58 outputJson({ success: false, error: message } satisfies ValidationError)
59 } else {
60 logError(message)
61 }
62 process.exit(exitCode)
63 }
64 }
65}
66
67async function validateDeepnoteFile(path: string | undefined, options: ValidateOptions): Promise<void> {
68 const { absolutePath } = await resolvePathToDeepnoteFile(path)

Callers 2

registerCommandsFunction · 0.90
validate.test.tsFile · 0.90

Calls 3

debugFunction · 0.90
outputJsonFunction · 0.90
validateDeepnoteFileFunction · 0.85

Tested by

no test coverage detected