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 🙏

© 2026 – Pkg Stats / Ryan Hefner

husky-commit-triggers

v1.0.0

Published

husky-commit-triggers automates environment setup tasks during branch checkouts. It scans commit messages for specific markers and automatically runs configured commands when you switch branches. The tool supports directional behavior by running one comma

Readme

husky-commit-triggers

husky-commit-triggers automates environment setup tasks during branch checkouts. It scans commit messages for specific markers and automatically runs configured commands when you switch branches. The tool supports directional behavior by running one command when moving to a newer commit ("up") and another when reverting to an older commit ("down").

Features

  • Automated Setup on Checkout: On branch switches, the tool scans commit messages between the previous and current commits for markers defined in your configuration.
  • Directional Behavior: It compares commit timestamps to determine whether you are moving "up" (to a newer commit) or "down" (to an older commit), executing the corresponding command.
  • Ordered Execution: Markers are processed in the order they appear in your package.json, and each marker is executed only once per checkout.
  • Simple Configuration: Define your commit triggers in your package.json without any extra setup.

Installation

Install the package from npm:

npm install husky-commit-triggers --save-dev

The package’s postinstall script will automatically:

  • Add a postCheckoutScripts property to your package.json if one does not already exist.
  • Set up a Husky post-checkout hook that runs the commit message scanning logic.

Configuration

Define your commit triggers in your package.json under the postCheckoutScripts property. Each key is a commit marker, and its value can be either a string (the default command) or an object with up and down keys for directional behavior. The order that the keys are defined in your package.json determines the order in which they are executed

For example:

"postCheckoutScripts": {
"install_dependencies": "npm install",
"migrate_db": {
"up": "node scripts/runMigrations.js",
"down": "node scripts/rollbackMigrations.js"
}
}

In this example:

  • A commit message containing [install_dependencies] will trigger npm install.
  • A commit message containing [migrate_db] will trigger node scripts/runMigrations.js when switching to a newer commit and node scripts/rollbackMigrations.js when switching to an older commit.

Usage

  1. Include Markers in Commit Messages: When making commits, include markers in square brackets. For example:

    • chore: update dependencies [install_dependencies]
    • feat: add new migration [migrate_db]
  2. Switch Branches: When you switch branches, the Husky post-checkout hook will:

    • Compare the commit timestamps between the branch you are leaving and the branch you are checking out.
    • Scan the commit messages in that range for any defined markers.
    • Execute the corresponding command for each marker in the order they are defined in your package.json.

Advanced Configuration

To control the verbosity of the output, you can set the LOG_LEVEL environment variable. For example, to display only error messages:

LOG_LEVEL=error

Contributing

Contributions are welcome! Please open issues or submit pull requests if you have suggestions or improvements.

License

This project is licensed under the MIT License.