-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Husky v4 doesn't load config when it is loaded using require
#662
Comments
require
require
Hi @gurpreetatwal, Thanks for the report. This is related to #648 Husky But since there's no I understand this defeats the purpose of an external config file, but this would make 'use strict';
// pre-commit
module.exports = require('./configs').husky; |
We distribute git hooks using a private package on |
Could a possible fix for this be in
This way for those who are using require (e.g. unknown hooks) then it grabs all the hooks and for those who aren't and are using specific hooks, only those get hooked. |
A robust solution might be to test for the existence of If someone is generating config dynamically, it's not safe to shortcut. partly because |
@codyhamilton I agree, do you want to make a PR? |
@JounQin just released it 👍 it includes @codyhamilton fix. For recent versions, you can find changes here: https://github.com/typicode/husky/releases |
@typicode Thx, and I know we can find changes at releases, but if you do not want to maintain CHANGLOG file anymore, it's better to clarify in the documentation, right? |
@typicode im not sure if this issue is fixed. I've upgraded to version Husky file in root of project:
Should this work? |
@antonsamper It does work to me. module.exports = require('@1stg/husky-config'); |
I believe Husky v4.0.0 might have a regression in regards to config file loading.
Given the following config file:
.huskyrc.js
where
./configs
isHusky prints the following (when running with
HUSKY_DEBUG=1
)Oddly enough everything seems to work again as soon as I put the name of the hook that I want to run anywhere in the config file (even embedded between words in a comment). So for example the following config:
gives:
OS:
Ubuntu 18.04.3 LTS
Terminal:
alacritty 0.2.3
Shell:
zsh 5.4.2 (x86_64-ubuntu-linux-gnu)
The text was updated successfully, but these errors were encountered: