Git hook to install dependencies on branch change or after a merge whenever the lock file changes
npm install git-install-hookInstall dependencies automatically when you change branches or merge and some new dependencies have been added or removed.
Made to be used with the post-checkout and post-merge hooks.
It detects the package manager automatically and installs the dependencies. You can prompt the user if you want to install the dependencies on change.
``bashnpm
npm install --save-dev git-install-hook
Usage
The command is supposed to run with
simple-git-hooks or husky.$3
`bash
run normally
git-install-hookAsk if you want to install the dependencies on change
git-install-hook --promptshow spinner instead of installation output
git-install-hook --installation spinnerdon't show information text output
git-install-hook --no-text
`$3
Install
simple-git-hooks and initialize it. After that you can add the hooks to your package.json. Below example is for pnpm. For npm and yarn you can use npx or yarn instead of pnpm exec.`json
"simple-git-hooks": {
"post-checkout": "pnpm exec git-install-hook",
"post-merge": "pnpm exec git-install-hook --prompt"
}
`Run the
simple-git-hooks command to install the hooks:`bash
npm
npx simple-git-hooksyarn
yarn simple-git-hookspnpm
pnpm exec simple-git-hooks
`$3
Run the prepare script to install the hooks:
`bash
npm
npx husky installyarn
yarn husky installpnpm
pnpm dlx husky install
`Add the
post-checkout or the post-merge hook:`bash
npm
npx husky add .husky/post-checkout "npx git-install-hook"yarn
yarn husky add .husky/post-checkout "yarn git-install-hook"pnpm
pnpm dlx husky add .husky/post-checkout "pnpm exec git-install-hook"
`Flags
-
--prompt - Ask if you want to install the dependencies on change.
- --debug - Show debug messages.
- --installation - Installation output. Can be show, hide or spinner. Default is show.
- --no-text` - Don't show information text output.