( _program: Command )
| 56 | } |
| 57 | |
| 58 | export function createDiffAction( |
| 59 | _program: Command |
| 60 | ): (path1: string | undefined, path2: string | undefined, options: DiffOptions) => Promise<void> { |
| 61 | return async (path1, path2, options) => { |
| 62 | try { |
| 63 | debug(`Diffing files: ${path1} vs ${path2}`) |
| 64 | debug(`Options: ${JSON.stringify(options)}`) |
| 65 | await diffDeepnoteFiles(path1, path2, options) |
| 66 | } catch (error) { |
| 67 | const message = error instanceof Error ? error.message : String(error) |
| 68 | const exitCode = error instanceof FileResolutionError ? ExitCode.InvalidUsage : ExitCode.Error |
| 69 | switch (options.output) { |
| 70 | case 'json': |
| 71 | outputJson({ success: false, error: message }) |
| 72 | break |
| 73 | case undefined: |
| 74 | logError(message) |
| 75 | break |
| 76 | } |
| 77 | process.exit(exitCode) |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | async function diffDeepnoteFiles( |
| 83 | path1: string | undefined, |
no test coverage detected