Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Node script to check npm version of package (expects piped in versions from npm)
'use strict';
const version = process.argv[2];
// Simple script to exit non-zero if the given version
// usage: npm view [package] versions | node vcheck [version]
// eg: npm view synthetix versions | node vcheck 2.4.1
process.stdin
.resume()
.setEncoding('utf8')
.on('data', function(data) {
const versions = JSON.parse(data.replace(/'/g, '"'));
if (versions.indexOf(version) >= 0) {
process.stdout.write(`${version} already published.\n`);
process.exitCode = 1;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.