I am trying to reuse husky for other projects (not just config file), building a lib of sorts that will be used by all other projects. I cannot understand how and when devinstall and devuninstall scripts are executed. Cannot find any documentation either on npmjs.com. Can someone help understand when this are getting executed please?
Asked
Active
Viewed 214 times
3
-
Both scripts appear to be executed in their CI tests as they are defined/run in both `.travis.yml` and `appveyor.yml`. See [here](https://github.com/typicode/husky/search?utf8=%E2%9C%93&q=%22npm+run+devinstall%22%2C+%22npm+run+devuninstall%22&type=) – RobC Nov 08 '18 at 14:30
-
1In that case how does it call the `_install` script during `npm install` that adds the git hooks? – Deep Vora Nov 08 '18 at 16:08
1 Answers
1
I've been trying to understand that too.
Turns out they do something at publication time that renames the _install
script into install
.
Here's the script field of the package.json found in the husky folder when installed through npm.
"scripts": {
"build": "del-cli lib && tsc",
"devinstall": "npm run build && npm run _install -- node_modules/husky && node scripts/dev-fix-path",
"devuninstall": "npm run build && npm run preuninstall -- node_modules/husky",
"fix": "npm run lint -- --fix",
"install": "node husky install",
"lint": "tslint 'src/**/*.ts'",
"postpublish": "pinst --disable",
"postversion": "git push && git push --tags",
"prepublishOnly": "npm run test && npm run build && pinst --enable && pkg-ok",
"preuninstall": "node husky uninstall",
"test": "npm run lint && jest",
"version": "jest -u && git add -A src/installer/__tests__/__snapshots__"
}
Although I can't figure where that is done

Giltho
- 92
- 9
-
I tried checking their build pipeline but did not find anything, may be I missed something. But I am pretty sure it happens during publish – Deep Vora Nov 26 '18 at 19:48