Socket
Socket
Sign inDemoInstall

git-hook-pure

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    git-hook-pure

git hook more freely and quickly


Version published
Weekly downloads
15
decreased by-53.12%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

git-hook-pure

You needn't bootstrap nodejs in every git hook

Install with npm/yarn

yarn add git-hook-pure -D

# or

npm install git-hook-pure --save-dev

Will create a folder .githooks in the same level as .git. And append code to all git hooks in .git/hooks.

You can put an executable file in .githooks/ or .githooks/[hookName]/.

The file under .githooks/ will be executed in all git hook and called by /path/to/hook-file [hook name] [...git hook arguments].

The file under .githooks/[hookName]/ will be executed in specified git hook and called by /path/to/hook-file [...git hook arguments].

Install without npm/yarn

bash -c "$(curl -fsSL https://raw.githubusercontent.com/bolasblack/git-hook-pure/master/install.sh)"

Work with git lfs

git lfs need install some git hook, you can run git lfs update -m to get hook scripts and put them in .githooks.

For example you can put lfs script .git/hooks/pre-push into .githooks/pre-push/git-lfs.

Or you can put script

#!/bin/sh

command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .githooks/git-lfs.\n"; exit 2; }

if [ \
  $1 = "pre-push" -o \
  $1 = "post-checkout" -o \
  $1 = "post-commit" -o \
  $1 = "post-merge" -o \
  ! t ] ; then
  git lfs "$@" || exit
fi

exit 0

into .githooks/git-lfs

Custom git-hook-template.sh

Change npm script to:

{
  // ...
  "scripts": {
    "postinstall": "./node_modules/git-hook-pure/git-hook-pure.sh install /the/path/to/template/file"
  }
}

Skip installation when running npm install

You can use the environment variable GIT_HOOK_PURE_SKIP_INSTALL=1 to avoid the running of the install scripts.

Not working with pnpm v7

  1. Add setting into project .npmrc: echo side-effects-cache=false > .npmrc
  2. Re-install dependencies: rm -f node_modules/.pnpm/lock.yaml && pnpm install
  3. Add a reaction to this issue and wish some day we can add this setting for git-hook-pure only: https://github.com/pnpm/pnpm/issues/5002

FAQs

Last updated on 29 Dec 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc