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

First husky add some command is not line-terminated #12

Closed
atifaziz opened this issue Dec 29, 2021 · 1 comment · Fixed by #13
Closed

First husky add some command is not line-terminated #12

atifaziz opened this issue Dec 29, 2021 · 1 comment · Fixed by #13
Assignees

Comments

@atifaziz
Copy link
Contributor

Running dotnet husky add with some command is not line-terminated. Another execution will put the second command together with the first one. The bug only happens for the first invocation.

To Reproduce

Run the following commands in a shell, in a new directory and in the shown sequence:

git init
dotnet new tool-manifest
dotnet tool install Husky
dotnet husky install
dotnet husky add .husky/pre-commit "echo 'Husky is awesome!'"
dotnet husky add .husky/pre-commit "echo 'Husky is awesome!'"
git commit --allow-empty -m "Keep calm and commit"

The final git commit will print the following:

Husky is awesome!echo Husky is awesome!
[master (root-commit) 656c076] Keep calm and commit

Note that what gets printed from the hook is the single line Husky is awesome!echo Husky is awesome!.

Expected behavior

I would have expected the following output:

Husky is awesome!
Husky is awesome!
[master (root-commit) 656c076] Keep calm and commit

That is Husky is awesome! printed on two separate lines.

Additional information

It's clear why this is happening when one inspects the content of .husky/pre-commit:

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

## husky task runner examples -------------------
## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky'

## run all tasks
#husky run

### run all tasks with group: 'group-name'
#husky run --group group-name

## run task with name: 'task-name'
#husky run --name task-name

## or put your custom commands -------------------
#echo 'Husky.Net is awesome!'

echo 'Husky is awesome!'echo 'Husky is awesome!'

The first command was not line-terminated.

This does not happen for subsequent runs of husky add. For example, following-up with the commands:

dotnet husky add .husky/pre-commit "echo 'Husky is awesome!'"
git commit --allow-empty -m "Keep calm and commit"

prints:

Husky is awesome!echo Husky is awesome!
Husky is awesome!
[master 51f1c2b] Keep calm and commit

The third addition correctly printed on its own line.

@atifaziz
Copy link
Contributor Author

Closed via f77ebfa that was a merge of PR #13.

@alirezanet alirezanet linked a pull request Dec 30, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants