File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ type OptionValue = boolean | string
2222
2323const options = new Map < string , OptionValue >
2424const commands : string [ ] = [ ]
25+ let didParseOption = false
26+ let didParseOptionAfterCommand = false
2527
2628for ( const argument of process . argv . slice ( 2 ) ) {
2729 if ( argument [ 0 ] == `-` ) {
@@ -48,8 +50,15 @@ for (const argument of process.argv.slice(2)) {
4850 for ( const option of key ! . slice ( 1 ) )
4951 options . set ( option , value )
5052 }
51- } else
53+
54+ didParseOption = true
55+ } else {
56+ if ( didParseOption ) {
57+ didParseOptionAfterCommand = true
58+ }
59+
5260 commands . push ( argument )
61+ }
5362}
5463
5564const pushModule = import ( `../push` )
@@ -83,6 +92,15 @@ const userColours = new AutoMap<string, string>(user => {
8392
8493const log = ( message : string ) => console . log ( colourS ( message ) )
8594
95+ if ( didParseOptionAfterCommand ) {
96+ process . exitCode = 1
97+
98+ console . warn ( colourF ( `\
99+ ${ chalk . bold ( `Warning:` ) } Options should come after commands when calling the script.
100+ This warning will become an error in the next minor version of HSM.`
101+ ) )
102+ }
103+
86104if ( process . version . startsWith ( `v21.` ) ) {
87105 process . exitCode = 1
88106
You can’t perform that action at this time.
0 commit comments