@@ -148,7 +148,7 @@ if (isWindows) {
148
148
cmd : 'script "quoted parameter"; second command' ,
149
149
} )
150
150
t . equal ( shell , 'blrorp' , 'used ComSpec as default shell' )
151
- t . match ( args , [ '-c' , / \. s h ' $ / ] , 'got expected args' )
151
+ t . match ( args , [ / \. s h $ / ] , 'got expected args' )
152
152
t . match ( opts , {
153
153
env : {
154
154
npm_package_json : / p a c k a g e \. j s o n $ / ,
@@ -160,7 +160,10 @@ if (isWindows) {
160
160
windowsVerbatimArguments : undefined ,
161
161
} , 'got expected options' )
162
162
163
- const filename = unescapeSh ( args [ args . length - 1 ] )
163
+ let filename = unescapeSh ( args [ args . length - 1 ] )
164
+ if ( process . platform === 'win32' ) {
165
+ filename = filename . replace ( / ^ \/ ( [ A - z ] ) / , '$1:' )
166
+ }
164
167
t . ok ( fs . existsSync ( filename ) , 'script file was written' )
165
168
cleanup ( )
166
169
t . not ( fs . existsSync ( filename ) , 'cleanup removes script file' )
@@ -325,7 +328,7 @@ if (isWindows) {
325
328
args : [ '"quoted parameter";' , 'second command' ] ,
326
329
} )
327
330
t . equal ( shell , 'sh' , 'defaults to sh' )
328
- t . match ( args , [ '-c' , / \. s h ' $ / ] , 'got expected args' )
331
+ t . match ( args , [ / \. s h $ / ] , 'got expected args' )
329
332
t . match ( opts , {
330
333
env : {
331
334
npm_package_json : / p a c k a g e \. j s o n $ / ,
@@ -339,7 +342,7 @@ if (isWindows) {
339
342
340
343
const filename = unescapeSh ( args [ args . length - 1 ] )
341
344
const contents = fs . readFileSync ( filename , { encoding : 'utf8' } )
342
- t . equal ( contents , `#!/usr/bin/env sh\nscript '"quoted parameter";' 'second command'` )
345
+ t . equal ( contents , `script '"quoted parameter";' 'second command'` )
343
346
t . ok ( fs . existsSync ( filename ) , 'script file was written' )
344
347
cleanup ( )
345
348
t . not ( fs . existsSync ( filename ) , 'cleanup removes script file' )
@@ -357,38 +360,7 @@ if (isWindows) {
357
360
t . equal ( shell , 'sh' , 'defaults to sh' )
358
361
// no-control-regex disabled because we're specifically testing control chars
359
362
// eslint-disable-next-line no-control-regex
360
- t . match ( args , [ '-c' , / (?: \\ | \/ ) [ ^ < : > / \x04 ] + \. s h ' $ / ] , 'got expected args' )
361
- t . match ( opts , {
362
- env : {
363
- npm_package_json : / p a c k a g e \. j s o n $ / ,
364
- npm_lifecycle_event : 'event' ,
365
- npm_lifecycle_script : 'script' ,
366
- } ,
367
- stdio : undefined ,
368
- cwd : 'path' ,
369
- windowsVerbatimArguments : undefined ,
370
- } , 'got expected options' )
371
-
372
- const filename = unescapeSh ( args [ args . length - 1 ] )
373
- const contents = fs . readFileSync ( filename , { encoding : 'utf8' } )
374
- t . equal ( contents , `#!/usr/bin/env sh\nscript '"quoted parameter";' 'second command'` )
375
- t . ok ( fs . existsSync ( filename ) , 'script file was written' )
376
- cleanup ( )
377
- t . not ( fs . existsSync ( filename ) , 'cleanup removes script file' )
378
-
379
- t . end ( )
380
- } )
381
-
382
- t . test ( 'skips /usr/bin/env if scriptShell is absolute' , ( t ) => {
383
- const [ shell , args , opts , cleanup ] = makeSpawnArgs ( {
384
- event : 'event' ,
385
- path : 'path' ,
386
- cmd : 'script' ,
387
- args : [ '"quoted parameter";' , 'second command' ] ,
388
- scriptShell : '/bin/sh' ,
389
- } )
390
- t . equal ( shell , '/bin/sh' , 'kept provided setting' )
391
- t . match ( args , [ '-c' , / \. s h ' $ / ] , 'got expected args' )
363
+ t . match ( args , [ / (?: \\ | \/ ) [ ^ < : > / \x04 ] + \. s h $ / ] , 'got expected args' )
392
364
t . match ( opts , {
393
365
env : {
394
366
npm_package_json : / p a c k a g e \. j s o n $ / ,
@@ -402,7 +374,7 @@ if (isWindows) {
402
374
403
375
const filename = unescapeSh ( args [ args . length - 1 ] )
404
376
const contents = fs . readFileSync ( filename , { encoding : 'utf8' } )
405
- t . equal ( contents , `#!/bin/sh\nscript '"quoted parameter";' 'second command'` )
377
+ t . equal ( contents , `script '"quoted parameter";' 'second command'` )
406
378
t . ok ( fs . existsSync ( filename ) , 'script file was written' )
407
379
cleanup ( )
408
380
t . not ( fs . existsSync ( filename ) , 'cleanup removes script file' )
0 commit comments