Skip to content

Instantly share code, notes, and snippets.

@alexeyten
Created April 23, 2020 06:47
Show Gist options
  • Save alexeyten/04a28b0c1ff38eb4ae0988e723a92401 to your computer and use it in GitHub Desktop.
Save alexeyten/04a28b0c1ff38eb4ae0988e723a92401 to your computer and use it in GitHub Desktop.
NPM (pre)version

Test (pre)version scripts

$ npm version 2.0.0

> test@2.0.0 preversion /tmp/test
> ./check.js

{ envVersion: '2.0.0', pkgVersion: '1.2.3' }
v2.0.0

> test@2.0.0 version /tmp/test
> ./check.js

{ envVersion: '2.0.0', pkgVersion: '2.0.0' }
#!/usr/bin/env node
console.log({
envVersion: process.env.npm_package_version,
pkgVersion: require('./package.json').version
});
{
"name": "test",
"version": "1.2.3",
"scripts": {
"preversion": "./check.js",
"version": "./check.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment