Skip to content

Commit

Permalink
fix prepare-commit-msg on windows (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkoman authored Dec 13, 2020
1 parent 65bc6e5 commit eb1eeb8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sh/husky.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/installer/__tests__/__snapshots__/scripts.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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\\"
Expand Down
3 changes: 1 addition & 2 deletions src/runner/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
6 changes: 3 additions & 3 deletions src/runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number> {
const oldCommand = getOldCommand(cwd, hookName)
Expand All @@ -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) {
Expand Down

0 comments on commit eb1eeb8

Please sign in to comment.