node package manager


Bump anything!


Bump packages :P or (basically) anything!

  • Ridiculously customizable, yet easy to use
  • Sane default configuration (bumps package.json-like files)
  • Supports both synchronous operations and promise-based async
  • No (zero, zip, zilch) hard dependencies
  • npm install bump-anything
  • (optional) install default dependencies if not customizing:
    • npm install semver when

The default configure method will return a "bumper" with the following expectations:

  • The locator points to a readable JSON file
  • The JSON document contains a "version" property at the root of the document

This works just fine with a standard "package.json" file.

var bumper = require("bump-anything").configure(),
    log = console.log,
    err = console.err;
bumper.major("package.json").then(log, err); // or 'minor' or 'patch' 
// > { oldVersion: "1.1.1", newVersion: "2.0.0" } 

To create a configured "bumper", you pass options to the configure method that will override the default configuration.

var myBumper = require("bump-anything").configure(options);

To create a "bumper" with the default configuration, omit the options, or pass undefined or null.

var bumper = require("bump-anything").configure();

Any of the following options can be overriden. Take care to match the interface of the default methods.

Returns the content from the location specified by locator.

By default, uses fs.readFileSync with encoding set to "utf8".

Write content to the location specified by locator.

By default, uses fs.writeFileSync with encoding set to "utf8".

Return the version found in content.

By default, parses content as JSON and returns the top-level version property.

Return content, modified to reflect the new version.

By default, parses content as JSON and updates the top-level version property, then returns "pretty" JSON stringified with 2 spaces.

Increment version using semantic type type, returning newVersion.

By default, uses npm's own semver package inc method.

Returns a promise by "piping" each method's result to the next.

By default, uses cujojs's when library's pipeline implementation.


Create a "bumper" with the given configuration options. If options are omitted, sane defaults will be used.

Bump the resource specified by locator with the given version type. The type must be one of: "major", "minor", or "patch".

The promise resolves with the following object:

  • locator: The locator specified in the call
  • type: The type specified in the call
  • oldVersion: The original version found in content
  • newVersion: The incremented version

Convenience method, calls bump with type set to "major".

Convenience method, calls bump with type set to "minor".

Convenience method, calls bump with type set to "patch".


Here are just a few examples of how to configure bump-anything for various tasks:

function writeContent(locator, content) {
  fs.writeFileSync(locator + ".new", content);
var bumper = require("bump-anything").configure({ writeContent: writeContent });
bumper.bump("package.json").done(); // bumps to "" 
function setVersion(content, version) {
    var data = JSON.parse(content),
        indent = 5;
    data.version = version;
    return JSON.stringify(data, null, indent);
function getVersion(content) {
  return JSON.parse(content).version.current;
function setVersion(content, version) {
  var data = JSON.parse(content);
  content.version.current = version;
  return content;
var bumper = require("bump-anything").configure({ getVersion: getVersion, setVersion: setVersion });