Skip to content

Commit 56c611d

Browse files
authored
Fix usage of SHELL environment variable can cause unexpected behavior #683
1 parent cbacd2e commit 56c611d

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/runner/__tests__/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ import index, { Env } from '../'
66

77
let spy: jest.SpyInstance
88

9-
// On AppVeyor $SHELL is not set
10-
process.env.SHELL = process.env.SHELL || 'sh'
11-
129
function expectSpawnSyncToHaveBeenCalledWith(
1310
cwd: string,
1411
cmd: string,
1512
env: Env = {}
1613
): void {
17-
expect(cp.spawnSync).toHaveBeenCalledWith(process.env.SHELL, ['-c', cmd], {
14+
expect(cp.spawnSync).toHaveBeenCalledWith('sh', ['-c', cmd], {
1815
cwd,
1916
env: { ...process.env, ...env },
2017
stdio: 'inherit'

src/runner/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ function runCommand(
3939
): number {
4040
console.log(`husky > ${hookName} (node ${process.version})`)
4141

42-
const SHELL = process.env.SHELL || 'sh'
43-
const { status } = spawnSync(SHELL, ['-c', cmd], {
42+
const { status } = spawnSync('sh', ['-c', cmd], {
4443
cwd,
4544
env: { ...process.env, ...env },
4645
stdio: 'inherit'

0 commit comments

Comments
 (0)