npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-git-hooks

v1.0.7

Published

Automate git hook deployment

Downloads

91,964

Readme

Cross-Platform Installation of Git Hooks

Git hooks are a powerful tool to help developers maintain consistency in their code. Unfortunately hooks are not part of the repository and thus require developers to manually set up and/or install them. There are a number of projects that address this, but they are not as automated, deployment-friendly, or cross-platform.

Node JS for Cross-Platform Support

Instead of using shell scripts which are dependent on the OS, this project uses Node to abstract filesystem operations. This allows it to run on Linux, OSX, Windows, any OS supported by Node.

Deployment Friendly

While automated installation of Git hooks is great for developers, it can cause problems during deployment. If an npm package post-installs hooks inside node_modules, build systems may throw the error Appears to be a git repo or submodule. This project will only copy hooks if the .git folder exists.

Tutorial

This article on dev.to has a detailed explanation and setup walk-through.

Installation

npm install node-git-hooks --save-dev

Usage

Create a .githooks folder and place hooks inside named corresponding to what they should be in .git/hooks. For example, the script pre-commit runs before a commit and is often used to perform linting. Remember to set the executable flag for hook files on *NIX systems:

chmod +x .githooks/*

Add the following prepare script to package.json:

"scripts": {
  "prepare": "node-git-hooks"
},

Run npm install to initialize the hooks.

Advanced Usage

If package.json is not located at the root of the repo (e.g. a multi-project repo), add the key node-git-hooks with the repo-path as such:

{
  "node-git-hooks": {
    "repo-path": "../"
  }
}

It is also possible to set the githooks folder path following the same logic:

{
  "node-git-hooks": {
    "githooks-path": "../"
  }
}