diff --git a/sh/husky.sh b/sh/husky.sh index f1542073f..c29bfbcf5 100644 --- a/sh/husky.sh +++ b/sh/husky.sh @@ -10,7 +10,7 @@ command_exists () { run_command () { if command_exists "$1"; then - "$@" husky-run $hookName "$gitParams" + "$@" husky-run $hookName $gitParams exitCode="$?" debug "$* husky-run exited with $exitCode exit code" diff --git a/src/installer/__tests__/__snapshots__/scripts.ts.snap b/src/installer/__tests__/__snapshots__/scripts.ts.snap index dd5d15345..50da308f3 100644 --- a/src/installer/__tests__/__snapshots__/scripts.ts.snap +++ b/src/installer/__tests__/__snapshots__/scripts.ts.snap @@ -39,7 +39,7 @@ command_exists () { run_command () { if command_exists \\"$1\\"; then - \\"$@\\" husky-run $hookName \\"$gitParams\\" + \\"$@\\" husky-run $hookName $gitParams exitCode=\\"$?\\" debug \\"$* husky-run exited with $exitCode exit code\\" diff --git a/src/runner/__tests__/index.ts b/src/runner/__tests__/index.ts index 729d6fab3..ea418c956 100644 --- a/src/runner/__tests__/index.ts +++ b/src/runner/__tests__/index.ts @@ -138,8 +138,7 @@ describe('run', (): void => { }) ) - // 'commit-msg' takes one parameter from git - const status = await index(['', '', 'commit-msg', 'git fake param'], { + const status = await index(['', '', 'commit-msg', 'git', 'fake', 'param'], { cwd: dir, }) expectSpawnSyncToHaveBeenCalledWith(dir, 'echo success', { diff --git a/src/runner/index.ts b/src/runner/index.ts index 05d1fe9c1..b13c9f78a 100644 --- a/src/runner/index.ts +++ b/src/runner/index.ts @@ -74,7 +74,7 @@ function runCommand( * @param {promise} options.getStdinFn - used for mocking only */ export default async function run( - [, , hookName = '', HUSKY_GIT_PARAMS]: string[], + [, , hookName = '', ...HUSKY_GIT_PARAMS]: string[], { cwd = process.cwd() }: { cwd?: string } = {} ): Promise { const oldCommand = getOldCommand(cwd, hookName) @@ -83,8 +83,8 @@ export default async function run( // Add HUSKY_GIT_PARAMS to env const env: Env = {} - if (HUSKY_GIT_PARAMS) { - env.HUSKY_GIT_PARAMS = HUSKY_GIT_PARAMS + if (HUSKY_GIT_PARAMS?.length) { + env.HUSKY_GIT_PARAMS = HUSKY_GIT_PARAMS.join(' ') } if (command) {