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
22
22
23
23
const options = new Map < string , OptionValue >
24
24
const commands : string [ ] = [ ]
25
+ let didParseOption = false
26
+ let didParseOptionAfterCommand = false
25
27
26
28
for ( const argument of process . argv . slice ( 2 ) ) {
27
29
if ( argument [ 0 ] == `-` ) {
@@ -48,8 +50,15 @@ for (const argument of process.argv.slice(2)) {
48
50
for ( const option of key ! . slice ( 1 ) )
49
51
options . set ( option , value )
50
52
}
51
- } else
53
+
54
+ didParseOption = true
55
+ } else {
56
+ if ( didParseOption ) {
57
+ didParseOptionAfterCommand = true
58
+ }
59
+
52
60
commands . push ( argument )
61
+ }
53
62
}
54
63
55
64
const pushModule = import ( `../push` )
@@ -83,6 +92,15 @@ const userColours = new AutoMap<string, string>(user => {
83
92
84
93
const log = ( message : string ) => console . log ( colourS ( message ) )
85
94
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
+
86
104
if ( process . version . startsWith ( `v21.` ) ) {
87
105
process . exitCode = 1
88
106
You can’t perform that action at this time.
0 commit comments