Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
'use strict';
var https = require('https');
var exec = require('child_process').exec;
var deletedPackageNamesUrl = 'https://gist.githubusercontent.com/azer/db27417ee84b5f34a6ea/raw/50ab7ef26dbde2d4ea52318a3590af78b2a21162/gistfile1.txt';
https.get(deletedPackageNamesUrl, function (res) {
var body = '';
res.on('data', function (chunk) {
body += chunk;
});
res.on('end', function () {
var deletedPackageNames = body.split('\n');
exec('npm ls --parseable', function (error, stdout, stderr) {
var lines = stdout.split('\n');
for (var i = 0; lines.length > i; i++) {
var line = lines[i];
var splittedPath = line.split('/');
if (splittedPath[splittedPath.length - 2] === 'node_modules') {
var packageName = splittedPath[splittedPath.length - 1];
for (var j = 0; deletedPackageNames.length > j; j++) {
var deletedPackageName = deletedPackageNames[j];
if (packageName === deletedPackageName) {
console.log(packageName + ' may be unpublished.');
}
}
}
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment