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

commit-template

v1.0.0

Published

Allows projects to define commit template files

Downloads

1,002

Readme

commit-template

Allows projects to define commit template files

The problem

Tools like commitlint, which examine commit messages and validate them as part of pre-commit hooks are great for ensuring quality messages from contributors, but can often be the cause of developer frustration when their use is not apparent to the author of the message.

A contributor may often not be aware of the use of such tools until after attempting to commit, by which time their message is lost, and needs to be completely re-written.

The solution

By allowing a project to define a template for a commit message it can be made clear to any contributors that their message must comply certain formats or standards before they write it.

Usage

Since commitlint uses husky to install hooks, it is expected that husky also installed.

npm install --save-dev husky commit-template

Then add the following to your package.json scripts:

"preparecommitmsg": "commit-template"

And add a file in the root of your project named .commit-msg. The contents of this file will then be used as your template commit message.

Customisation

If you want to use a different file name for your template file, this can be passed as an argument to the npm script:

"preparecommitmsg": "commit-template .my-template-file"

Advanced usage

If you want more complex behaviour for your commit templates - such as reading git branch names - then you can set the template to a local js module.

If the module exports a function then it will be executed, and the return value used as the commit template. Otherwise if the module exports a string then that will be used as the template.

Example

// .commit-msg
const branch = require('git-branch');
module.exports = () => `[${branch.sync()}]`;

Note: functions are called with await so may be async if needed.

Testing

Running npm run preparecommitmsg will output the resolved message without needing to make a commit.