11const _ = require ( 'lodash' )
22const async = require ( 'async' )
3- const gutil = require ( 'gulp-util' )
3+ const PluginError = require ( 'plugin-error' )
4+ const fancyLog = require ( 'fancy-log' )
5+ const template = require ( 'lodash.template' )
6+ const chalk = require ( 'chalk' )
47const path = require ( 'path' )
58const spawn = require ( 'child_process' ) . spawn
69const through = require ( 'through2' )
@@ -13,7 +16,7 @@ function normalizeCommands (commands) {
1316 }
1417
1518 if ( ! Array . isArray ( commands ) ) {
16- throw new gutil . PluginError ( PLUGIN_NAME , 'Missing commands' )
19+ throw new PluginError ( PLUGIN_NAME , 'Missing commands' )
1720 }
1821
1922 return commands
@@ -40,15 +43,15 @@ function normalizeOptions (options) {
4043function runCommands ( commands , options , file , done ) {
4144 async . eachSeries ( commands , ( command , done ) => {
4245 const context = _ . extend ( { file} , options . templateData )
43- command = gutil . template ( command , context )
46+ command = template ( command ) ( context )
4447
4548 if ( options . verbose ) {
46- gutil . log ( gutil . colors . cyan ( command ) )
49+ fancyLog ( chalk . cyan ( command ) )
4750 }
4851
4952 const child = spawn ( command , {
5053 env : options . env ,
51- cwd : gutil . template ( options . cwd , context ) ,
54+ cwd : template ( options . cwd ) ( context ) ,
5255 shell : options . shell ,
5356 stdio : options . quiet ? 'ignore' : 'inherit'
5457 } )
@@ -64,9 +67,9 @@ function runCommands (commands, options, file, done) {
6467 error : { code}
6568 } , options . templateData )
6669
67- const message = gutil . template ( options . errorMessage , context )
70+ const message = template ( options . errorMessage ) ( context )
6871
69- done ( new gutil . PluginError ( PLUGIN_NAME , message ) )
72+ done ( new PluginError ( PLUGIN_NAME , message ) )
7073 } )
7174 } , done )
7275}
0 commit comments