Skip to content

Instantly share code, notes, and snippets.

@jjgonecrypto
Created May 14, 2019 17:27
Show Gist options
  • Save jjgonecrypto/0e2370c25cd529567e0483821bf7542a to your computer and use it in GitHub Desktop.
Save jjgonecrypto/0e2370c25cd529567e0483821bf7542a to your computer and use it in GitHub Desktop.
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