Skip to content

husky add command escapes string with positional parameters ($1) #1019

@remarkablemark

Description

@remarkablemark

Troubleshoot

If you're migrating from husky 4, see:
https://typicode.github.io/husky/#/?id=migrate-from-v4-to-v7

Context
Please describe your issue and provide some context:

  • Terminal or GUI client (PowerShell, Git Bash, GitHub Desktop, ...)
    • macOS iTerm2 ZSH
  • If applicable, content of the failing hook
    • See below
  • If possible, minimal steps to reproduce the issue:

Create empty directory with git:

$ mkdir test && cd test && git init

Install husky:

$ npx husky install
husky - Git hooks installed

Running command from docs:

$ npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"'
husky - created .husky/commit-msg

Expected output of .husky/commit-msg:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"

Actual output of cat .husky/commit-msg:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit ""

My version of husky:

$ npm ls husky
test@1.0.0 /Users/remarkablemark/test
└── husky@7.0.1

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions