npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

version-changed

2.0.0 • Public • Published

version-changed

Checks if the version in package.json has changed since the last commit.

Node version Build Status JavaScript Style Guide

Install

$ npm i version-changed -S|-D|-g

Usage

In code:

const versionChanged = require('version-changed')
versionChanged((err, changed) => {
  if (err) throw err
  console.log('version changed', changed)
})

On command line:

$ version-changed && ./dosomething

When used in package.json it's more handy to shortcut with ||. For this reason you can use version-unchanged.

The prebuild script below will run prebuildify if the version has changed, but will not fail if the version didn't change.

{
  "scripts": {
    "prebuild": "version-unchanged || prebuildify --napi"
  }
}

API

versionChanged(err, cb)

Calls back with (err, changed) where changed is true if the version in package.json at the current commit has changed compared to the previous commit, otherwise false.

CLI

version-changed

Exits with 0 if the version has changed. Use this together with &&.

version-unchanged

Exits with 0 if the version is unchanged. Use this together with ||.

Kudos

This code was extracted from prebuild-ci. Kudos to @juliangruber. ❤️

License

MIT

install

npm i version-changed

Downloadsweekly downloads

229

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability