@@ -266,6 +266,117 @@ fn cached_only_after_first_run() {
266
266
assert_contains ! ( stdout, "createChalk: chalk" ) ;
267
267
}
268
268
269
+ #[ test]
270
+ fn reload_flag ( ) {
271
+ let _server = http_server ( ) ;
272
+
273
+ let deno_dir = util:: new_deno_dir ( ) ;
274
+
275
+ let deno = util:: deno_cmd_with_deno_dir ( & deno_dir)
276
+ . current_dir ( util:: testdata_path ( ) )
277
+ . arg ( "run" )
278
+ . arg ( "--unstable" )
279
+ . arg ( "--allow-read" )
280
+ . arg ( "--allow-env" )
281
+ . arg ( "npm/reload/main.ts" )
282
+ . env ( "NO_COLOR" , "1" )
283
+ . envs ( env_vars ( ) )
284
+ . stdout ( Stdio :: piped ( ) )
285
+ . stderr ( Stdio :: piped ( ) )
286
+ . spawn ( )
287
+ . unwrap ( ) ;
288
+ let output = deno. wait_with_output ( ) . unwrap ( ) ;
289
+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
290
+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
291
+ assert_contains ! ( stderr, "Download" ) ;
292
+ assert_contains ! ( stdout, "createChalk: chalk" ) ;
293
+ assert ! ( output. status. success( ) ) ;
294
+
295
+ let deno = util:: deno_cmd_with_deno_dir ( & deno_dir)
296
+ . current_dir ( util:: testdata_path ( ) )
297
+ . arg ( "run" )
298
+ . arg ( "--unstable" )
299
+ . arg ( "--allow-read" )
300
+ . arg ( "--allow-env" )
301
+ . arg ( "--reload" )
302
+ . arg ( "npm/reload/main.ts" )
303
+ . env ( "NO_COLOR" , "1" )
304
+ . envs ( env_vars ( ) )
305
+ . stdout ( Stdio :: piped ( ) )
306
+ . stderr ( Stdio :: piped ( ) )
307
+ . spawn ( )
308
+ . unwrap ( ) ;
309
+ let output = deno. wait_with_output ( ) . unwrap ( ) ;
310
+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
311
+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
312
+ assert_contains ! ( stderr, "Download" ) ;
313
+ assert_contains ! ( stdout, "createChalk: chalk" ) ;
314
+ assert ! ( output. status. success( ) ) ;
315
+
316
+ let deno = util:: deno_cmd_with_deno_dir ( & deno_dir)
317
+ . current_dir ( util:: testdata_path ( ) )
318
+ . arg ( "run" )
319
+ . arg ( "--unstable" )
320
+ . arg ( "--allow-read" )
321
+ . arg ( "--allow-env" )
322
+ . arg ( "--reload=npm:" )
323
+ . arg ( "npm/reload/main.ts" )
324
+ . env ( "NO_COLOR" , "1" )
325
+ . envs ( env_vars ( ) )
326
+ . stdout ( Stdio :: piped ( ) )
327
+ . stderr ( Stdio :: piped ( ) )
328
+ . spawn ( )
329
+ . unwrap ( ) ;
330
+ let output = deno. wait_with_output ( ) . unwrap ( ) ;
331
+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
332
+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
333
+ assert_contains ! ( stderr, "Download" ) ;
334
+ assert_contains ! ( stdout, "createChalk: chalk" ) ;
335
+ assert ! ( output. status. success( ) ) ;
336
+
337
+ let deno = util:: deno_cmd_with_deno_dir ( & deno_dir)
338
+ . current_dir ( util:: testdata_path ( ) )
339
+ . arg ( "run" )
340
+ . arg ( "--unstable" )
341
+ . arg ( "--allow-read" )
342
+ . arg ( "--allow-env" )
343
+ . arg ( "--reload=npm:chalk" )
344
+ . arg ( "npm/reload/main.ts" )
345
+ . env ( "NO_COLOR" , "1" )
346
+ . envs ( env_vars ( ) )
347
+ . stdout ( Stdio :: piped ( ) )
348
+ . stderr ( Stdio :: piped ( ) )
349
+ . spawn ( )
350
+ . unwrap ( ) ;
351
+ let output = deno. wait_with_output ( ) . unwrap ( ) ;
352
+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
353
+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
354
+ assert_contains ! ( stderr, "Download" ) ;
355
+ assert_contains ! ( stdout, "createChalk: chalk" ) ;
356
+ assert ! ( output. status. success( ) ) ;
357
+
358
+ let deno = util:: deno_cmd_with_deno_dir ( & deno_dir)
359
+ . current_dir ( util:: testdata_path ( ) )
360
+ . arg ( "run" )
361
+ . arg ( "--unstable" )
362
+ . arg ( "--allow-read" )
363
+ . arg ( "--allow-env" )
364
+ . arg ( "--reload=npm:foobar" )
365
+ . arg ( "npm/reload/main.ts" )
366
+ . env ( "NO_COLOR" , "1" )
367
+ . envs ( env_vars ( ) )
368
+ . stdout ( Stdio :: piped ( ) )
369
+ . stderr ( Stdio :: piped ( ) )
370
+ . spawn ( )
371
+ . unwrap ( ) ;
372
+ let output = deno. wait_with_output ( ) . unwrap ( ) ;
373
+ let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
374
+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
375
+ assert ! ( stderr. is_empty( ) ) ;
376
+ assert_contains ! ( stdout, "createChalk: chalk" ) ;
377
+ assert ! ( output. status. success( ) ) ;
378
+ }
379
+
269
380
#[ test]
270
381
fn no_npm_after_first_run ( ) {
271
382
let _server = http_server ( ) ;
0 commit comments