Last active
July 1, 2017 05:33
-
-
Save charmander/bc81d9ca9b05d686ef04c9769eb8b25a to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env node | |
'use strict'; | |
const https = require('https'); | |
const semver = require('semver'); | |
const readUtf8 = stream => | |
new Promise((resolve, reject) => { | |
const parts = []; | |
stream.on('error', reject); | |
stream.on('data', part => { | |
parts.push(part); | |
}); | |
stream.on('end', () => { | |
resolve(Buffer.concat(parts).toString('utf8')); | |
}); | |
}); | |
const username = process.argv[2]; | |
if (!username) { | |
console.error('Usage: sub-1.0 <username>'); | |
process.exit(1); | |
return; | |
} | |
const request = https.get('https://registry.npmjs.com/-/v1/search?size=250&text=maintainer:' + encodeURIComponent(username)); | |
request.on('response', async response => { | |
const json = await readUtf8(response); | |
const data = JSON.parse(json); | |
const packages = data.objects.map(object => object.package); | |
const unstable = packages.filter(package_ => semver.lt(package_.version, '1.0.0')); | |
const unstableNames = unstable.map(package_ => package_.name); | |
console.log(unstableNames.sort().join('\n')); | |
}); |
This file contains 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
{ | |
"name": "sub-1.0", | |
"bin": "main.js", | |
"dependencies": { | |
"semver": "5.3.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment