Created
March 16, 2016 06:16
-
-
Save qrg/c0788da0676339ef5f67 to your computer and use it in GitHub Desktop.
`$ node ~/scripts/check-gulp-blacklist.js [SEARCHWORD]`
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
| #!/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