Skip to content

Commit

Permalink
Fix usage of SHELL environment variable can cause unexpected behavior #…
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Apr 9, 2020
1 parent cbacd2e commit 56c611d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/runner/__tests__/index.ts
Expand Up @@ -6,15 +6,12 @@ import index, { Env } from '../'

let spy: jest.SpyInstance

// On AppVeyor $SHELL is not set
process.env.SHELL = process.env.SHELL || 'sh'

function expectSpawnSyncToHaveBeenCalledWith(
cwd: string,
cmd: string,
env: Env = {}
): void {
expect(cp.spawnSync).toHaveBeenCalledWith(process.env.SHELL, ['-c', cmd], {
expect(cp.spawnSync).toHaveBeenCalledWith('sh', ['-c', cmd], {
cwd,
env: { ...process.env, ...env },
stdio: 'inherit'
Expand Down
3 changes: 1 addition & 2 deletions src/runner/index.ts
Expand Up @@ -39,8 +39,7 @@ function runCommand(
): number {
console.log(`husky > ${hookName} (node ${process.version})`)

const SHELL = process.env.SHELL || 'sh'
const { status } = spawnSync(SHELL, ['-c', cmd], {
const { status } = spawnSync('sh', ['-c', cmd], {
cwd,
env: { ...process.env, ...env },
stdio: 'inherit'
Expand Down

0 comments on commit 56c611d

Please sign in to comment.