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

npm-version-bump

v1.0.0

Published

Inject custom modifications into the npm version commit

Downloads

94

Readme

npm-version-bump

A programmatic version of the npm version command which allows you to inject custom modifications into the version commit.

Build status js-standard-style

Installation

npm install --save npm-version-bump

Examples

Update the package.json version property, commit it to git and tag the commit:

var bump = require('npm-version-bump')

var dir = '/path/to/module'
var version = 'patch'

bump(dir, version, function (err) {
  if (err) throw err
})

Update the package.json version property, perform custom modifications to files tracked by the git repository and finally commit everything in a single commit and tag it as a version commit:

var exec = require('child_process').exec
var bump = require('npm-version-bump')

var dir = '/path/to/module'
var version = '2.0.0'

bump(dir, version, precommit, function (err) {
  if (err) throw err
})

function precommit (callback) {
  exec('./build.sh', callback)
}

API

When you require the npm-version-bump module, the bump function is returned:

bump(dir, version, [precommit], [callback])

The bump function accepts the following arguments:

  • dir - The base directory of the npm module whos version you'd like to modify. It's expected that this directory contains a package.json file with a version property.

    If the directory is not a git repository, this module will still work as normal, except it will not commit anything.

  • version - A string representing the <newversion> part of the the npm version <newversion> command. It can be either a legal semver version or one of the following convenience bump commands:

    major | minor | patch | premajor | preminor | prepatch | prerelease
  • precommit - An optional function that will be called before the actual git commit is performed. This allows you to modify any file in the git repository so they in turn will be included in the final version commit.

    The function will be called with a callback as the first argument which you must call when you are done. Calling this callback will trigger the commit.

    If this function is provided, the callback argument must also be provided.

  • callback - An optional function that will be called after the git commit has been performed.

    The callback will be parsed an Error object as the first argument in case either the commit could not be performed or the commit could not be tagged.

License

MIT