Skip to content

Instantly share code, notes, and snippets.

@qrg
Created March 16, 2016 06:16
Show Gist options
  • Select an option

  • Save qrg/c0788da0676339ef5f67 to your computer and use it in GitHub Desktop.

Select an option

Save qrg/c0788da0676339ef5f67 to your computer and use it in GitHub Desktop.
`$ node ~/scripts/check-gulp-blacklist.js [SEARCHWORD]`
#!/usr/bin/env node
'use strict';
const https = require('https');
const argv = process.argv[2];
const uri = 'https://raw.githubusercontent.com/gulpjs/plugins/master/src/blackList.json';
const isEmpty = (obj) => {
return Object.keys(obj).length === 0 && JSON.stringify(obj) === JSON.stringify({})
};
https.get(uri, (res) => {
let body = '';
res.setEncoding('utf8');
res.on('data', (chunk) => {
body += chunk;
});
res.on('end', (res) => {
const list = JSON.parse(body);
if (argv) {
let results = {};
for (let item in list) {
if (item.includes(argv) || list[item].includes(argv)) {
results[item] = list[item];
}
}
if (isEmpty(results)) {
console.log('Nothing.');
return;
}
console.log(results);
return;
}
console.log(list);
return;
});
}).on('error', (e) => {
console.error(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment