@@ -11,7 +11,7 @@ export class DbOperationsCommand {
1111 @Command ( 'migrate:status {--connection==}' , {
1212 desc : 'Command to show the status of all migrations' ,
1313 } )
14- async migrateStatus ( _cli : ConsoleIO ) : Promise < void > {
14+ async migrateStatus ( _cli : ConsoleIO ) : Promise < void | boolean > {
1515 const options = ObjectionService . config ;
1616
1717 const conn = _cli . option < string > ( 'connection' ) || options . default ;
@@ -31,13 +31,13 @@ export class DbOperationsCommand {
3131 }
3232
3333 _cli . table ( [ 'Migration' , 'Status' ] , statusList ) ;
34- process . exit ( ) ;
34+ return true ;
3535 }
3636
3737 @Command ( 'migrate {--connection==}' , {
3838 desc : 'Command to run the pending migrations' ,
3939 } )
40- async migrationUp ( _cli : ConsoleIO ) : Promise < void > {
40+ async migrationUp ( _cli : ConsoleIO ) : Promise < void | boolean > {
4141 const options = ObjectionService . config ;
4242 const conn = _cli . option < string > ( 'connection' ) || options . default ;
4343 const knex = ObjectionService . connection ( conn ) ;
@@ -49,21 +49,21 @@ export class DbOperationsCommand {
4949
5050 if ( migrations . length === 0 ) {
5151 _cli . info ( 'No migrations to run' ) ;
52- process . exit ( ) ;
52+ return true ;
5353 }
5454
5555 _cli . info ( `Batch Number: ${ batch } ` ) ;
5656 for ( const migration of migrations ) {
5757 _cli . success ( migration ) ;
5858 }
5959
60- process . exit ( ) ;
60+ return true ;
6161 }
6262
6363 @Command ( 'migrate:rollback {--connection==}' , {
6464 desc : 'Command to rollback the previous batch of migrations' ,
6565 } )
66- async migrateRollback ( _cli : ConsoleIO ) {
66+ async migrateRollback ( _cli : ConsoleIO ) : Promise < void | boolean > {
6767 const options = ObjectionService . config ;
6868 const conn = _cli . option < string > ( 'connection' ) || options . default ;
6969 const knex = ObjectionService . connection ( conn ) ;
@@ -75,21 +75,21 @@ export class DbOperationsCommand {
7575
7676 if ( migrations . length === 0 ) {
7777 _cli . info ( 'No migrations to rollback. Already at the base migration' ) ;
78- process . exit ( ) ;
78+ return true ;
7979 }
8080
8181 _cli . info ( `Reverted Batch: ${ batch } ` ) ;
8282 for ( const migration of migrations ) {
8383 _cli . success ( migration ) ;
8484 }
8585
86- process . exit ( ) ;
86+ return true ;
8787 }
8888
8989 @Command ( 'migrate:reset {--connection==}' , {
9090 desc : 'Command to reset the migration' ,
9191 } )
92- async migrateReset ( _cli : ConsoleIO ) {
92+ async migrateReset ( _cli : ConsoleIO ) : Promise < boolean > {
9393 const options = ObjectionService . config ;
9494 const conn = _cli . option < string > ( 'connection' ) || options . default ;
9595 const knex = ObjectionService . connection ( conn ) ;
@@ -101,7 +101,7 @@ export class DbOperationsCommand {
101101
102102 if ( ! confirm ) {
103103 _cli . info ( 'Thank you! Exiting...' ) ;
104- process . exit ( ) ;
104+ return true ;
105105 }
106106
107107 const password = await _cli . password (
@@ -112,7 +112,7 @@ export class DbOperationsCommand {
112112 const conPassword = connConfig . connection ?. [ 'password' ] ;
113113 if ( conPassword && password !== conPassword ) {
114114 _cli . error ( ' Wrong Password. Exiting... ' ) ;
115- process . exit ( ) ;
115+ return true ;
116116 }
117117 }
118118
@@ -122,21 +122,21 @@ export class DbOperationsCommand {
122122
123123 if ( migrations . length === 0 ) {
124124 _cli . info ( 'No migrations to rollback. Already at the base migration' ) ;
125- process . exit ( ) ;
125+ return true ;
126126 }
127127
128128 _cli . info ( 'Rollback of following migrations are done:' ) ;
129129 for ( const migration of migrations ) {
130130 _cli . success ( migration ) ;
131131 }
132132
133- process . exit ( ) ;
133+ return true ;
134134 }
135135
136136 @Command ( 'make:migration {name} {--connection=}' , {
137137 desc : 'Command to create a new migration' ,
138138 } )
139- async makeMigration ( _cli : ConsoleIO ) {
139+ async makeMigration ( _cli : ConsoleIO ) : Promise < boolean > {
140140 const options = ObjectionService . config ;
141141 const name = _cli . argument < string > ( 'name' ) ;
142142 const conn = _cli . option < string > ( 'connection' ) || options . default ;
@@ -150,6 +150,6 @@ export class DbOperationsCommand {
150150
151151 const paths = res . split ( '/' ) ;
152152 _cli . success ( paths [ paths . length - 1 ] ) ;
153- process . exit ( ) ;
153+ return true ;
154154 }
155155}
0 commit comments