-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
var http = require('http'); | ||
|
||
/** | ||
* Given a collection of plugin names verifies this collection against | ||
* the black-list. Invokes callback with an object: | ||
* [plugin name]=>[black-listing reason] | ||
* or undefined if none of the plugins to check is black-listed. | ||
* | ||
* @param pluginsToVerify - an array of plugin names to verify | ||
* @param cb | ||
*/ | ||
module.exports = function (pluginsToVerify, cb) { | ||
http.get('http://gulpjs.com/plugins/blackList.json', function (res) { | ||
var blackListJSONStr = ''; | ||
|
||
res.on('data', function (chunk) { | ||
blackListJSONStr += chunk; | ||
}); | ||
|
||
res.on('end', function () { | ||
var blackList = JSON.parse(blackListJSONStr); | ||
var result = pluginsToVerify.reduce(function(blackListed, pluginName) { | ||
if (blackList[pluginName]) { | ||
blackListed = blackListed || {}; | ||
blackListed[pluginName] = blackList[pluginName]; | ||
return blackListed; | ||
} | ||
}); | ||
cb(null, result); | ||
}); | ||
|
||
}).on('error', function (e) { | ||
cb(e); | ||
}); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
var chalk = require('chalk'); | ||
var gutil = require('gulp-util'); | ||
var blackList = require('./blackList'); | ||
var formatError = require('./formatError'); | ||
|
||
module.exports = function verifyDependencies(depNames) { | ||
|
||
blackList(Object.keys(depNames), function(err, blackListed) { | ||
if (err) { | ||
gutil.log(chalk.red('Error: failed to retrieve plugins black-list')); | ||
gutil.log(formatError(err)); | ||
process.exit(1); | ||
} | ||
|
||
if (blackListed) { | ||
gutil.log(chalk.red('Black-listed plugins found in this project:')); | ||
for (var blDependency in blackListed) { | ||
gutil.log(blDependency + ': ' + blackListed[blDependency]); | ||
} | ||
process.exit(1); | ||
} else { | ||
gutil.log( | ||
chalk.green('There are no black-listed plugins in this project') | ||
); | ||
process.exit(0); | ||
} | ||
}); | ||
}; |