@@ -17,17 +17,23 @@ export type Flags = {
1717} ;
1818
1919function defaultFlags ( flags : Partial < Flags > , defaults : Partial < Flags > ) {
20+ flags = { ...defaults , ...flags } ;
21+
2022 for ( const [ key , value ] of Object . entries ( flags ) ) {
2123 if ( value !== undefined && ! ( key in defaults ) ) {
2224 throw new Error ( `Option '${ key } ' is unsupported for this command` ) ;
2325 }
2426
27+ const defaultValue = defaults [ key as keyof Flags ] ;
2528 // should we default the flag?
2629 if ( value === undefined ) {
27- flags [ key as keyof Flags ] = defaults [ key as keyof Flags ] ;
30+ flags [ key as keyof Flags ] = defaultValue ;
2831 }
29- }
3032
33+ if ( typeof value !== typeof defaultValue ) {
34+ throw new Error ( `Option '${ key } ' should be of type ${ typeof defaultValue } ` ) ;
35+ }
36+ }
3137 return flags as Flags ;
3238}
3339
@@ -67,16 +73,6 @@ export async function cli(cwd: string, argv: string[]) {
6773 trigger prisma to run migrations as part of startup
6874 ` ,
6975 {
70- allowUnknownFlags : false ,
71- flags : {
72- dbPush : { type : 'boolean' } ,
73- frozen : { type : 'boolean' } ,
74- prisma : { type : 'boolean' } ,
75- server : { type : 'boolean' } ,
76- ui : { type : 'boolean' } ,
77- withMigrations : { type : 'boolean' } ,
78- fix : { type : 'boolean' } , // TODO: remove - deprecated
79- } ,
8076 argv,
8177 }
8278 ) ;
0 commit comments