@@ -352,29 +352,30 @@ describe("getStderrHandler", () => {
352
352
353
353
describe ( "defaultShell" , ( ) => {
354
354
const sandbox = sinon . createSandbox ( ) ;
355
- let restoreEnv : RestoreFn = ( ) => { } ;
356
355
afterEach ( ( ) => {
357
356
sandbox . restore ( ) ;
358
- restoreEnv ( ) ;
359
357
} ) ;
360
358
it ( "SHELL" , async ( ) => {
361
- restoreEnv = mockedEnv ( { SHELL : "/bin/bash" } ) ;
359
+ sandbox . stub ( process , "env" ) . value ( { SHELL : "/bin/bash" } ) ;
362
360
const result = await defaultShell ( ) ;
363
361
assert . equal ( result , "/bin/bash" ) ;
364
362
} ) ;
365
363
it ( "darwin - /bin/zsh" , async ( ) => {
364
+ sandbox . stub ( process , "env" ) . value ( { } ) ;
366
365
sandbox . stub ( process , "platform" ) . value ( "darwin" ) ;
367
366
sandbox . stub ( fs , "pathExists" ) . resolves ( true ) ;
368
367
const result = await defaultShell ( ) ;
369
368
assert . equal ( result , "/bin/zsh" ) ;
370
369
} ) ;
371
370
it ( "darwin - /bin/bash" , async ( ) => {
371
+ sandbox . stub ( process , "env" ) . value ( { } ) ;
372
372
sandbox . stub ( process , "platform" ) . value ( "darwin" ) ;
373
373
sandbox . stub ( fs , "pathExists" ) . onFirstCall ( ) . resolves ( false ) . onSecondCall ( ) . resolves ( true ) ;
374
374
const result = await defaultShell ( ) ;
375
375
assert . equal ( result , "/bin/bash" ) ;
376
376
} ) ;
377
377
it ( "darwin - undefined" , async ( ) => {
378
+ sandbox . stub ( process , "env" ) . value ( { } ) ;
378
379
sandbox . stub ( process , "platform" ) . value ( "darwin" ) ;
379
380
sandbox . stub ( fs , "pathExists" ) . resolves ( false ) ;
380
381
const result = await defaultShell ( ) ;
@@ -383,25 +384,27 @@ describe("defaultShell", () => {
383
384
384
385
it ( "win32 - ComSpec" , async ( ) => {
385
386
sandbox . stub ( process , "platform" ) . value ( "win32" ) ;
386
- restoreEnv = mockedEnv ( { ComSpec : "cmd.exe" } ) ;
387
+ sandbox . stub ( process , "env" ) . value ( { ComSpec : "cmd.exe" } ) ;
387
388
const result = await defaultShell ( ) ;
388
389
assert . equal ( result , "cmd.exe" ) ;
389
390
} ) ;
390
391
it ( "win32 - cmd.exe" , async ( ) => {
391
392
sandbox . stub ( process , "platform" ) . value ( "win32" ) ;
392
- restoreEnv = mockedEnv ( { ComSpec : undefined } ) ;
393
+ sandbox . stub ( process , "env" ) . value ( { } ) ;
393
394
const result = await defaultShell ( ) ;
394
395
assert . equal ( result , "cmd.exe" ) ;
395
396
} ) ;
396
397
397
398
it ( "other OS - /bin/sh" , async ( ) => {
399
+ sandbox . stub ( process , "env" ) . value ( { } ) ;
398
400
sandbox . stub ( process , "platform" ) . value ( "other" ) ;
399
401
sandbox . stub ( fs , "pathExists" ) . resolves ( true ) ;
400
402
const result = await defaultShell ( ) ;
401
403
assert . equal ( result , "/bin/sh" ) ;
402
404
} ) ;
403
405
404
406
it ( "other OS - undefined" , async ( ) => {
407
+ sandbox . stub ( process , "env" ) . value ( { } ) ;
405
408
sandbox . stub ( process , "platform" ) . value ( "other" ) ;
406
409
sandbox . stub ( fs , "pathExists" ) . resolves ( false ) ;
407
410
const result = await defaultShell ( ) ;
0 commit comments