Open make-github-pseudonymous-again opened 2 months ago
Would it work to only run husky
if we detect that it has been installed? Or do we have to disable this for npm
entirely?
Would it work to only run
husky
if we detect that it has been installed? Or do we have to disable this fornpm
entirely?
We have to disable this for npm
entirely, see for instance:
npm ERR! code 1
npm ERR! path ./node_modules/@async-abstraction/tape
npm ERR! command failed
npm ERR! command sh -c npm run install-hooks
npm ERR! > @async-abstraction/tape@10.0.0 install-hooks
npm ERR! > husky install
npm ERR! husky - .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory)
According to husky
's own docs, not running the postinstall
script on npm install
can be achieved with
{
"scripts": {
// Yarn doesn't support prepare script
"postinstall": "husky",
// Include this if publishing to npmjs.com
"prepack": "pinst --disable",
"postpack": "pinst --enable"
}
}
This requires pinst
as a dev dependency:
yarn add --dev husky
# Add pinst ONLY if your package is not private
yarn add --dev pinst
And not when installing the package itself. Currently,
npm install package
will fail because it tries to run thehusky
installation, buthusky
is a dev dependency.