File tree 3 files changed +25
-8
lines changed
3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change 1
1
import type { ArgsDef , CommandDef } from 'citty'
2
2
import { consola } from 'consola'
3
3
import { colorize } from 'consola/utils'
4
+ import { process } from 'std-env'
4
5
import { CommonArgs } from '../../arguments/common.mjs'
5
6
import { usingSeeder } from '../../seeds/using-seeder.mjs'
6
7
import { createSubcommand } from '../../utils/create-subcommand.mjs'
8
+ import { exitWithError , handleAggregateError } from '../../utils/error.mjs'
7
9
8
10
const args = {
9
11
...CommonArgs ,
@@ -62,6 +64,11 @@ const BaseRunCommand = {
62
64
} `,
63
65
)
64
66
}
67
+
68
+ if ( error ) {
69
+ handleAggregateError ( error )
70
+ exitWithError ( error )
71
+ }
65
72
} ,
66
73
} satisfies CommandDef < typeof args >
67
74
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { consola } from 'consola'
2
2
import { colorize } from 'consola/utils'
3
3
import type { MigrationResultSet , Migrator } from 'kysely'
4
4
import { process } from 'std-env'
5
+ import { exitWithError , handleAggregateError } from '../utils/error.mjs'
5
6
import { getMigrations } from './get-migrations.mjs'
6
7
7
8
export async function processMigrationResultSet (
@@ -22,14 +23,8 @@ export async function processMigrationResultSet(
22
23
} `,
23
24
)
24
25
25
- if ( error instanceof AggregateError ) {
26
- for ( const subError of error . errors ) {
27
- consola . error ( subError )
28
- }
29
- }
30
-
31
- process . exit ?.( 1 )
32
- throw error
26
+ handleAggregateError ( error )
27
+ exitWithError ( error )
33
28
}
34
29
35
30
if ( ! results ?. length ) {
Original file line number Diff line number Diff line change
1
+ import { consola } from 'consola'
2
+ import { process } from 'std-env'
3
+
4
+ export function handleAggregateError ( error : unknown ) : void {
5
+ if ( error instanceof AggregateError ) {
6
+ for ( const subError of error . errors ) {
7
+ consola . error ( subError )
8
+ }
9
+ }
10
+ }
11
+
12
+ export function exitWithError ( error : unknown ) : never {
13
+ process . exit ?.( 1 )
14
+ throw error
15
+ }
You can’t perform that action at this time.
0 commit comments