question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to husky prepare-commit-msg on windows?

See original GitHub issue

Using husky it is very useful but script which is there is designed only for bash purpose.

"husky": {
  "hooks": {
    "prepare-commit-msg": "exec < /dev/tty && git cz --hook",
  }
}

What could be solution for Windows?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:45
  • Comments:25 (5 by maintainers)

github_iconTop GitHub Comments

36reactions
shardoolcommented, Nov 8, 2019

@neilime, Although your trick works, I seem to be running into the following issue where the up and down arrow keys causes this very annoying duplication effect. I’m on Windows 7 Enterprise, Git version 2.24.0.windows.2
commitizen

17reactions
neilimecommented, Oct 31, 2019

Hi,

I’ve found something that works on my windows 10, with pure batch (bat) scripts (so it does not require bash or git bash)

precommit-msg

In my package.json:

{
  "husky": {
    "hooks": {
      "prepare-commit-msg": "prepare-commit-msg",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

I have created two bat files at the root of my repo:

  1. prepare-commit-msg.cmd
@ECHO off
SETLOCAL

CALL :find_dp0
set "_prog=%dp0%exec-git-cz.cmd"
IF NOT EXIST "%_prog%" (
    ECHO "%_prog% does not exist"
    ENDLOCAL
    EXIT /b 1
)
start /wait call "%_prog%" --hook %*)

:find_dp0
SET dp0=%~dp0
EXIT /b
  1. exec-git-cz.cmd
@ECHO off
SETLOCAL

CALL :find_dp0
set "_prog=%dp0%node_modules\.bin\git-cz.cmd"
IF NOT EXIST "%_prog%" (
    ECHO "%_prog% does not exist, please install commitizen"
    ENDLOCAL
    EXIT /b 1
)

call "%_prog%" %*

ENDLOCAL
EXIT %errorlevel%

:find_dp0
SET dp0=%~dp0
EXIT /b
Read more comments on GitHub >

github_iconTop Results From Across the Web

Husky - Git hooks
Husky improves your commits and more woof! You can use it to lint your commit messages, run tests, lint code, etc... when you...
Read more >
How to Add Commit Hooks to Git with Husky to Automate ...
How to Add Commit Hooks to Git with Husky to Automate Code Tasks · Step 0: How to set up a new project...
Read more >
Getting Started with Git Hooks and Husky | Tower Blog
Run a linter to check commit messages. Run a linter to style/format committed code. Compress any images added to the project. Run Jest...
Read more >
Git pre-commit hook is not running on Windows - Stack Overflow
Name your hook pre-commit (without any file extension). And add #!/bin/sh on the first line or #!/bin/bash .
Read more >
Making yarn and husky hooks work with windows - Jesse Baird
ZB17-JMYrepos3.0node_modules.binhusky-run: command not found Can't find Husky, skipping prepare-commit-msg hook You can reinstall it using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found