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

nanocommit

v1.15.1

Published

Commit every time your tests pass, no fuss, no muss

Downloads

1,161

Readme

nanocommit

Table Of Contents

Why nanocommit?

Nanocommit (properly, "nanocommit") is a tool which will commit your code for you when your tests pass. This means you can work all day and, each time you run your commits, your work will be saved! (That's all it does.)

Currently, nanocommit is aimed at Node and Javascript packages which contain a package.json file. If there is enough demand, I will extend functionality.

Setting Up nanocommit

Installation

Easiest setup: For one-time menu-driven package-level installation, run the following command:

npx nanocommit --init

The above command will set up the configuration you need in your package to use nanocommit, and will install the package locally for you. The menu system should be straightforward. If you have any feedback, please submit it to the nanocommit github issues board.

You can either install nanocommit globally:

npm install nanocommit -g

Or you can install it locally to a package:

npm install nanocommit --save-dev

Configuration

Note

If you ran npx nanocommit --init and chose to install nanocommit locally, you don't need to do any other configuration.

Everyone else:

If you installed nanocommit globally, run the following command and follow the prompts:

nanocommit --init

Configuration By Hand

This is not recommended. Please use --init unless you really, really know what you intend to do.

Configuration Options

Below is an example of a nanocommit configuration in the package.json file. This will generally be generated, but can be edited by hand.

{
    ...
    "nanocommit": {
        "testCommand": "mocha ./spec/**/*.spec.js",
        "defaultCommandArgs": null,
        "blindCommit": true,
        "commitMessage": "All tests passed",
        "annotations": null
    }
    ...
}

The following is a stand-alone nanocommit config (.nanocommit.config.json). This will only be read if there is no package.json file in your project. The standalone configuration is ideal for non-javascript projects.

{
    "testCommand": "npm run test-and-build",
    "defaultCommandArgs": null,
    "blindCommit": true,
    "commitMessage": null,
    "annotations": "nanocommit",
    "watchFiles": [
        "./app/**/*.js"
    ],
    "customAnnotations": null,
    "playSound": true
}

Following are the configuration options. It is advisable to simply run nanocommit --init, or npx nanocommit --init to set these options instead of configuring by hand.

  • testCommand -- The testCommand option defaults to npm test but will accept any terminal command you might use to run your tests.

  • defaultCommandArgs -- An array of arguments which are typically passed to the test command. If arguments are supplied via the CLI, they will replace the default command args.

  • blindCommit -- The blindCommit default is "false." This option tells nanocommit whether you want to choose what is committed, or if you'd prefer everything be committed without user intervention.

  • commitMessage -- The commitMessage default is null, requiring the user to enter a commit message. If a commit message is specified, nanocommit will not prompt for a commit message, instead using the message specified, appended with a date/time stamp.

  • annotations -- There are two options for automated commit message annotations: nanocommit and arlo. Nanocommit annotations are in brackets and contain common words or abbreviations, e.g. [doc] for documentation. Arlo style annotations reflect Arlo Belshee's annotation list, found in his github repo: https://github.com/arlobelshee/ArlosCommitNotation

  • watchFiles -- An array of glob patterns for files to watch and retest on.

  • playSound -- Play a bell ringing sound when tests pass

Running Nanocommit

Nanocommit Basics

It is possible to run nanocommit in a couple different ways: locally and as a global script.

When nanocommit is installed locally, run this from your package root:

node ./node_modules/nanocommit/

If nanocommit is installed and configured to run from the npm test command, you can pass flags through like the following example:

Important note: the -- is required by npm. Don't forget to include it!

npm test -- --test-only

If nanocommit is installed globally, just run this:

nanocommit

Nanocommit Flags

All flags for nanocommit are simply standalone and accept no arguments. Currently the following are supported:

  • nanocommit --help -- This will display help information about nanocommit and a very simple explanation of how to run it.

  • nanocommit --init -- This will initialize your project with a nanocommit configuration. The configuration will reside in your package.json file if you have one, otherwise it will exist in a standalone file called .nanocommit.conf.json.

  • nanocommit --commit-only -- This will run just the commit portion of the nanocommit run, skipping the testing phase. This is especially helpful if you either have no tests currently (sad face), you ran the tests and just want the tag annotations, or you are committing changes which are not necessarily part of the production code.

  • nanocommit --test-only -- This will run just the test portion of the nanocommit run, skipping the commit phase. This is especially helpful when you want to just run tests and get an output (like in a deployment situation).

  • nanocommit --watch -- Watches files in configuration, reruns tests and commits when tests pass.