Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix prepare-commit-msg on windows #737

Merged
merged 3 commits into from Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion sh/husky.sh
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
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
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
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