Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub desktop Husky pre-commit hook does not

I installed husky@4 and lint-staged as per many other projects (on Mac OS11). The terminal command flow git add . and git commit -m 'something' flow works fine: Husky's pre-commit hook and lint-staged commands are picked up successfully. However, the Github Desktop pre-commit hook does not seem to be behaving.

I have tried looking in the the .git/hooks/pre-commit file and it's there:

#!/bin/sh
# husky

# Created by Husky v4.3.8 (https://github.com/typicode/husky#readme)
#   At: 3/7/2021, 12:09:26 PM
#   From: /Users/admin/devProj/prject/node_modules/husky (https://github.com/typicode/husky#readme)

. "$(dirname "$0")/husky.sh"

Commands:

...
        "husky": "^4.3.8",
        "lint-staged": "^10.5.4",
...
"husky": {
        "hooks": {
            "pre-commit": "tsc --noEmit && lint-staged"
        }
    },
    "lint-staged": {
        "**/*.(js|jsx|ts|tsx)": [
            "npm run lint:fix",
            "prettier --write"
        ]
    }

Any other reasons why GitHub Desktop is not finding this?

like image 433
Phil Lucks Avatar asked Mar 15 '26 23:03

Phil Lucks


1 Answers

Having the same problem, I eventually found a solution here

Essentially, do the following:

Add a file to your root directory ~/.huskyrc that contains the following

PATH="/usr/local/bin:$PATH"

Restart Github Desktop, and voila :)

like image 74
sfletche Avatar answered Mar 18 '26 02:03

sfletche



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!