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

v5: why does a custom directory require package.json? #827

Closed
ericcornelissen opened this issue Dec 8, 2020 · 3 comments
Closed

v5: why does a custom directory require package.json? #827

ericcornelissen opened this issue Dec 8, 2020 · 3 comments

Comments

@ericcornelissen
Copy link
Contributor

@ericcornelissen ericcornelissen commented Dec 8, 2020

The v5 documentation says you can install Husky into a custom directory with the install command by specifying a custom path. However, the source requires this custom directory to have a package.json file (see below), but that doesn't seem necessary to me. I did some manual testing (commenting out the snippet below in node_modules/husky) and installed into a subdirectory and as far as I can tell everything works fine (including running NPM scripts, but even if that wasn't possible I don't know why that must be supported), but maybe I'm missing something...

if (!fs.existsSync(path.join(absoluteHooksDir, 'package.json'))) {
throw new Error("package.json can't be found")
}

Relatedly, the first example in the "Custom directory" documentation suggests to me that I can install the hooks into a directory called .config instead of .husky, but the result of the example would be that the hooks are installed into .config/.husky. Not sure if that is just me reading it wrong or if it is a mistake in the documentation.

In any case, I would like to see the option to change the name of the .husky folder in addition to changing the directory, would you be open to such a feature @typicode? My initial suggestion for this would be to have a separate option+argument for that, e.g. husky install custom/dir -dirname .config.

@typicode
Copy link
Owner

@typicode typicode commented Dec 8, 2020

The fact that the custom dir requires package.json is likely a bug I think.
Overall this part is a bit rough around the edges, I do plan to improve that this week.
Thanks for the feedback 👍

@typicode
Copy link
Owner

@typicode typicode commented Dec 11, 2020

Should be good with v5.0.6, I've updated documentation.

@ericcornelissen
Copy link
Contributor Author

@ericcornelissen ericcornelissen commented Dec 12, 2020

Works as expected now, awesome 👍 Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants