@@ -98,6 +98,28 @@ assert.match(
98
98
// FIXME: Should be 0
99
99
assert . equal ( out . status , 1 ) ;
100
100
101
+ // FIXME: Has the same problem with `rescript -w`
102
+ out = child_process . spawnSync ( `../../../rescript` , [ "-w" , "--help" ] , {
103
+ encoding : "utf8" ,
104
+ cwd : __dirname ,
105
+ } ) ;
106
+ assert . equal ( out . stdout , ">>>> Start compiling\n" + buildHelp ) ;
107
+ assert . match (
108
+ out . stderr ,
109
+ new RegExp (
110
+ "Uncaught Exception Error: ENOENT: no such file or directory, watch 'bsconfig.json'\n"
111
+ )
112
+ ) ;
113
+
114
+ // Shows cli help with --help arg even if there are invalid arguments after it
115
+ out = child_process . spawnSync ( `../../../rescript` , [ "--help" , "-w" ] , {
116
+ encoding : "utf8" ,
117
+ cwd : __dirname ,
118
+ } ) ;
119
+ assert . equal ( out . stdout , cliHelp ) ;
120
+ assert . equal ( out . stderr , "" ) ;
121
+ assert . equal ( out . status , 0 ) ;
122
+
101
123
// Shows build help with -h arg
102
124
out = child_process . spawnSync ( `../../../rescript` , [ "build" , "-h" ] , {
103
125
encoding : "utf8" ,
@@ -108,12 +130,12 @@ assert.equal(out.stderr, "");
108
130
assert . equal ( out . status , 0 ) ;
109
131
110
132
// Exits with build help with unknown arg
111
- out = child_process . spawnSync ( `../../../rescript` , [ "build" , "-wtf " ] , {
133
+ out = child_process . spawnSync ( `../../../rescript` , [ "build" , "-foo " ] , {
112
134
encoding : "utf8" ,
113
135
cwd : __dirname ,
114
136
} ) ;
115
137
assert . equal ( out . stdout , "" ) ;
116
- assert . equal ( out . stderr , 'Error: Unknown option "-wtf ".\n' + buildHelp ) ;
138
+ assert . equal ( out . stderr , 'Error: Unknown option "-foo ".\n' + buildHelp ) ;
117
139
assert . equal ( out . status , 2 ) ;
118
140
119
141
// Shows cli help with --help arg
@@ -143,22 +165,22 @@ assert.equal(out.stdout, cliHelp);
143
165
assert . equal ( out . stderr , "" ) ;
144
166
assert . equal ( out . status , 0 ) ;
145
167
146
- // Shows cli help with unknown command
168
+ // Exits with cli help with unknown command
147
169
out = child_process . spawnSync ( `../../../rescript` , [ "built" ] , {
148
170
encoding : "utf8" ,
149
171
cwd : __dirname ,
150
172
} ) ;
151
173
assert . equal ( out . stdout , "" ) ;
152
- assert . equal ( out . stderr , `Error: Unknown command or flag "built".\n` + cliHelp ) ;
174
+ assert . equal ( out . stderr , `Error: Unknown command "built".\n` + cliHelp ) ;
153
175
assert . equal ( out . status , 2 ) ;
154
176
155
- // Shows cli help with unknown args
156
- out = child_process . spawnSync ( `../../../rescript` , [ "-w " ] , {
177
+ // Exits with build help with unknown args
178
+ out = child_process . spawnSync ( `../../../rescript` , [ "-foo " ] , {
157
179
encoding : "utf8" ,
158
180
cwd : __dirname ,
159
181
} ) ;
160
182
assert . equal ( out . stdout , "" ) ;
161
- assert . equal ( out . stderr , ` Error: Unknown command or flag "-w ".\n` + cliHelp ) ;
183
+ assert . equal ( out . stderr , ' Error: Unknown option "-foo ".\n' + buildHelp ) ;
162
184
assert . equal ( out . status , 2 ) ;
163
185
164
186
// Shows clean help with --help arg
@@ -180,12 +202,12 @@ assert.equal(out.stderr, "");
180
202
assert . equal ( out . status , 0 ) ;
181
203
182
204
// Exits with clean help with unknown arg
183
- out = child_process . spawnSync ( `../../../rescript` , [ "clean" , "-wtf " ] , {
205
+ out = child_process . spawnSync ( `../../../rescript` , [ "clean" , "-foo " ] , {
184
206
encoding : "utf8" ,
185
207
cwd : __dirname ,
186
208
} ) ;
187
209
assert . equal ( out . stdout , "" ) ;
188
- assert . equal ( out . stderr , 'Error: Unknown option "-wtf ".\n' + cleanHelp ) ;
210
+ assert . equal ( out . stderr , 'Error: Unknown option "-foo ".\n' + cleanHelp ) ;
189
211
assert . equal ( out . status , 2 ) ;
190
212
191
213
// Shows format help with --help arg
0 commit comments