File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ gulp has very few flags to know about. All other flags are for tasks to use if n
1010- ` --cwd <dir path> ` will manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here
1111- ` -T ` or ` --tasks ` will display the task dependency tree for the loaded gulpfile
1212- ` --tasks-simple ` will display a plaintext list of tasks for the loaded gulpfile
13+ - ` --verify ` will verify plugins referenced in project's package.json against the plugins black list
1314- ` --color ` will force gulp and gulp plugins to display colors even when no color support is detected
1415- ` --no-color ` will force gulp and gulp plugins to not display colors even when color support is detected
1516- ` --silent ` will disable all gulp logging
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ var http = require ( 'http' ) ;
4+
5+ /**
6+ * Given a collection of plugin names verifies this collection against
7+ * the black-list. Invokes callback with an object:
8+ * [plugin name]=>[black-listing reason]
9+ * or undefined if none of the plugins to check is black-listed.
10+ *
11+ * @param pluginsToVerify - an array of plugin names to verify
12+ * @param cb
13+ */
14+ module . exports = function ( pluginsToVerify , cb ) {
15+ http . get ( 'http://gulpjs.com/plugins/blackList.json' , function ( res ) {
16+ var blackListJSONStr = '' ;
17+
18+ res . on ( 'data' , function ( chunk ) {
19+ blackListJSONStr += chunk ;
20+ } ) ;
21+
22+ res . on ( 'end' , function ( ) {
23+ var blackList = JSON . parse ( blackListJSONStr ) ;
24+ var result = pluginsToVerify . reduce ( function ( blackListed , pluginName ) {
25+ if ( blackList [ pluginName ] ) {
26+ blackListed = blackListed || { } ;
27+ blackListed [ pluginName ] = blackList [ pluginName ] ;
28+ return blackListed ;
29+ }
30+ } ) ;
31+ cb ( null , result ) ;
32+ } ) ;
33+
34+ } ) . on ( 'error' , function ( e ) {
35+ cb ( e ) ;
36+ } ) ;
37+ } ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ var chalk = require ( 'chalk' ) ;
4+ var gutil = require ( 'gulp-util' ) ;
5+ var blackList = require ( './blackList' ) ;
6+ var formatError = require ( './formatError' ) ;
7+
8+ module . exports = function verifyDependencies ( depNames ) {
9+
10+ blackList ( Object . keys ( depNames ) , function ( err , blackListed ) {
11+ if ( err ) {
12+ gutil . log ( chalk . red ( 'Error: failed to retrieve plugins black-list' ) ) ;
13+ gutil . log ( formatError ( err ) ) ;
14+ process . exit ( 1 ) ;
15+ }
16+
17+ if ( blackListed ) {
18+ gutil . log ( chalk . red ( 'Black-listed plugins found in this project:' ) ) ;
19+ for ( var blDependency in blackListed ) {
20+ gutil . log ( blDependency + ': ' + blackListed [ blDependency ] ) ;
21+ }
22+ process . exit ( 1 ) ;
23+ } else {
24+ gutil . log (
25+ chalk . green ( 'There are no black-listed plugins in this project' )
26+ ) ;
27+ process . exit ( 0 ) ;
28+ }
29+ } ) ;
30+ } ;
You can’t perform that action at this time.
0 commit comments