Back to directory
frontsideair avatar

yarnhook

Run `yarn install`, `npm install` or `pnpm install` on git hooks automatically. Read more below about its uses, features, and usage.

Clone repository

git clone https://github.com/frontsideair/yarnhook.git

219

Stars

16

Forks

3

Watchers

MIT

License

yarnhook npm version

yarnhook

yarnhook keeps your node_modules up-to-date when your yarn.lock, package-lock.json or shrinkwrap.yaml changes due to git operations like checkout, merge, rebase, pull etc.

Easy installation

You can install yarnhook to your project with mrm.

npx mrm yarnhook

Manual installation

This package should be used with husky.

yarn add --dev yarnhook husky
# or
npm install --save-dev yarnhook husky
# or
pnpm install --save-dev yarnhook husky

Configuration

You should let yarnhook handle git hooks that change the dependencies. Example package.json is as follows:

{
  "husky": {
    "hooks": {
      "post-checkout": "yarnhook",
      "post-merge": "yarnhook",
      "post-rewrite": "yarnhook"
    }
  }
}

Flags

Prepend these flags to your git command to use them.

  • YARNHOOK_BYPASS: Run git command bypassing yarnhook completely
  • YARNHOOK_DEBUG: Print debug information
  • YARNHOOK_DRYRUN: Don't install dependencies, only notify

An example:

YARNHOOK_BYPASS=true git checkout feature-branch

Artwork

Project logo: @anilkilic

Font: PT Sans

Releases

Nov 25, 2023

v0.6.1 support for bun

Download .zip

yarnhook now supports bun as a package manager, thanks @rwu823 for the contribution!

Jun 2, 2022

No --no-optional

Download .zip

This release removes the default --no-optional flag, see thread for context. This is a major release with breaking changes if you were relying on not installing the optional dependencies. While having...

Jun 2, 2022

pnpm v7 support

Download .zip

This version fixes the broken behavior at pnpm version 7, thanks to @TxHawks for reporting!

Sep 26, 2019

Support pnpm-lock.yaml

Download .zip

Support for pnpm-lock.yaml thanks to @mathdroid!

Jul 30, 2019

Fixed another security issue

Download .zip

Don't forget to upgrade!