Skip to content

Instantly share code, notes, and snippets.

@y13i
Created March 23, 2016 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save y13i/e6d43a57548d7af3cfea to your computer and use it in GitHub Desktop.
Save y13i/e6d43a57548d7af3cfea to your computer and use it in GitHub Desktop.
'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