Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/commands/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export const importCommand = new Command('import')
}

await runCarImport(importOptions)
} catch (error) {
console.error('Import failed:', error instanceof Error ? error.message : error)
} catch {
process.exit(1)
}
})
Expand Down
7 changes: 3 additions & 4 deletions src/import/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export async function runCarImport(options: ImportOptions): Promise<ImportResult
const proceed = await warnAboutCDNPricingLimitations()
if (!proceed) {
cancel('Import cancelled')
process.exitCode = 1
throw new Error('CDN pricing limitations warning cancelled')
}
}
Expand All @@ -158,7 +157,7 @@ export async function runCarImport(options: ImportOptions): Promise<ImportResult
if (!fileValidation.exists || !fileValidation.stats) {
spinner.stop(`${pc.red('✗')} ${fileValidation.error}`)
cancel('Import cancelled')
process.exit(1)
throw new Error(fileValidation.error)
}
const fileStat = fileValidation.stats

Expand All @@ -169,7 +168,7 @@ export async function runCarImport(options: ImportOptions): Promise<ImportResult
} catch (error) {
spinner.stop(`${pc.red('✗')} Invalid CAR file: ${error instanceof Error ? error.message : 'Unknown error'}`)
cancel('Import cancelled')
process.exit(1)
throw new Error('Invalid CAR file')
}

// Step 3: Handle root CID cases
Expand Down Expand Up @@ -290,6 +289,6 @@ export async function runCarImport(options: ImportOptions): Promise<ImportResult
await cleanupSynapseService()

cancel('Import failed')
process.exit(1)
throw error
}
}
10 changes: 4 additions & 6 deletions src/test/unit/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ describe('CAR Import', () => {
privateKey: testPrivateKey,
}

await expect(runCarImport(options)).rejects.toThrow('process.exit called')
expect(consoleMocks.error).toHaveBeenCalledWith('Import cancelled')
await expect(runCarImport(options)).rejects.toThrow()
})

it('should reject non-existent file', async () => {
Expand All @@ -348,8 +347,7 @@ describe('CAR Import', () => {
privateKey: testPrivateKey,
}

await expect(runCarImport(options)).rejects.toThrow('process.exit called')
expect(consoleMocks.error).toHaveBeenCalledWith('Import cancelled')
await expect(runCarImport(options)).rejects.toThrow()
})
})

Expand Down Expand Up @@ -394,7 +392,7 @@ describe('CAR Import', () => {
// No private key provided
}

await expect(runCarImport(options)).rejects.toThrow('process.exit called')
await expect(runCarImport(options)).rejects.toThrow()
// The error is caught and logged generically as "Import failed"
expect(consoleMocks.error).toHaveBeenCalled()
})
Expand Down Expand Up @@ -493,7 +491,7 @@ describe('CAR Import', () => {
privateKey: testPrivateKey,
}

await expect(runCarImport(options)).rejects.toThrow('process.exit called')
await expect(runCarImport(options)).rejects.toThrow()
expect(cleanupSpy).toHaveBeenCalled()
})
})
Expand Down
Loading