Created
May 14, 2019 17:27
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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