Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eb1eeb8

Browse files
authoredDec 13, 2020
fix prepare-commit-msg on windows (#737)
1 parent 65bc6e5 commit eb1eeb8

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed
 

‎sh/husky.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ command_exists () {
1010

1111
run_command () {
1212
if command_exists "$1"; then
13-
"$@" husky-run $hookName "$gitParams"
13+
"$@" husky-run $hookName $gitParams
1414

1515
exitCode="$?"
1616
debug "$* husky-run exited with $exitCode exit code"

‎src/installer/__tests__/__snapshots__/scripts.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ command_exists () {
3939
4040
run_command () {
4141
if command_exists \\"$1\\"; then
42-
\\"$@\\" husky-run $hookName \\"$gitParams\\"
42+
\\"$@\\" husky-run $hookName $gitParams
4343
4444
exitCode=\\"$?\\"
4545
debug \\"$* husky-run exited with $exitCode exit code\\"

‎src/runner/__tests__/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ describe('run', (): void => {
138138
})
139139
)
140140

141-
// 'commit-msg' takes one parameter from git
142-
const status = await index(['', '', 'commit-msg', 'git fake param'], {
141+
const status = await index(['', '', 'commit-msg', 'git', 'fake', 'param'], {
143142
cwd: dir,
144143
})
145144
expectSpawnSyncToHaveBeenCalledWith(dir, 'echo success', {

‎src/runner/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function runCommand(
7474
* @param {promise} options.getStdinFn - used for mocking only
7575
*/
7676
export default async function run(
77-
[, , hookName = '', HUSKY_GIT_PARAMS]: string[],
77+
[, , hookName = '', ...HUSKY_GIT_PARAMS]: string[],
7878
{ cwd = process.cwd() }: { cwd?: string } = {}
7979
): Promise<number> {
8080
const oldCommand = getOldCommand(cwd, hookName)
@@ -83,8 +83,8 @@ export default async function run(
8383
// Add HUSKY_GIT_PARAMS to env
8484
const env: Env = {}
8585

86-
if (HUSKY_GIT_PARAMS) {
87-
env.HUSKY_GIT_PARAMS = HUSKY_GIT_PARAMS
86+
if (HUSKY_GIT_PARAMS?.length) {
87+
env.HUSKY_GIT_PARAMS = HUSKY_GIT_PARAMS.join(' ')
8888
}
8989

9090
if (command) {

0 commit comments

Comments
 (0)
Please sign in to comment.