3
3
'use strict' ;
4
4
var fs = require ( 'fs' ) ;
5
5
var path = require ( 'path' ) ;
6
- var gutil = require ( 'gulp-util ' ) ;
6
+ var log = require ( 'gulplog ' ) ;
7
7
var chalk = require ( 'chalk' ) ;
8
8
var yargs = require ( 'yargs' ) ;
9
9
var Liftoff = require ( 'liftoff' ) ;
@@ -17,6 +17,7 @@ var completion = require('./lib/shared/completion');
17
17
var verifyDeps = require ( './lib/shared/verifyDependencies' ) ;
18
18
var cliVersion = require ( './package.json' ) . version ;
19
19
var getBlacklist = require ( './lib/shared/getBlacklist' ) ;
20
+ var toConsole = require ( './lib/shared/log/toConsole' ) ;
20
21
21
22
// Logging functions
22
23
var logVerify = require ( './lib/shared/log/verify' ) ;
@@ -51,27 +52,22 @@ if (opts.continue) {
51
52
process . env . UNDERTAKER_SETTLE = 'true' ;
52
53
}
53
54
54
- // This is a hold-over until we have a better logging system
55
- // with log levels
56
- var shouldLog = ! opts . silent && ! opts . tasksSimple ;
57
-
58
- if ( ! shouldLog ) {
59
- gutil . log = function ( ) { } ;
60
- }
55
+ // Set up event listeners for logging.
56
+ toConsole ( log , opts ) ;
61
57
62
58
cli . on ( 'require' , function ( name ) {
63
- gutil . log ( 'Requiring external module' , chalk . magenta ( name ) ) ;
59
+ log . info ( 'Requiring external module' , chalk . magenta ( name ) ) ;
64
60
} ) ;
65
61
66
62
cli . on ( 'requireFail' , function ( name ) {
67
- gutil . log ( chalk . red ( 'Failed to load external module' ) , chalk . magenta ( name ) ) ;
63
+ log . error ( chalk . red ( 'Failed to load external module' ) , chalk . magenta ( name ) ) ;
68
64
} ) ;
69
65
70
66
cli . on ( 'respawn' , function ( flags , child ) {
71
67
var nodeFlags = chalk . magenta ( flags . join ( ', ' ) ) ;
72
68
var pid = chalk . magenta ( child . pid ) ;
73
- gutil . log ( 'Node flags detected:' , nodeFlags ) ;
74
- gutil . log ( 'Respawned to PID:' , pid ) ;
69
+ log . info ( 'Node flags detected:' , nodeFlags ) ;
70
+ log . info ( 'Respawned to PID:' , pid ) ;
75
71
} ) ;
76
72
77
73
function run ( ) {
@@ -93,9 +89,9 @@ function handleArguments(env) {
93
89
}
94
90
95
91
if ( opts . version ) {
96
- gutil . log ( 'CLI version' , cliVersion ) ;
92
+ log . info ( 'CLI version' , cliVersion ) ;
97
93
if ( env . modulePackage && typeof env . modulePackage . version !== 'undefined' ) {
98
- gutil . log ( 'Local version' , env . modulePackage . version ) ;
94
+ log . info ( 'Local version' , env . modulePackage . version ) ;
99
95
}
100
96
exit ( 0 ) ;
101
97
}
@@ -105,7 +101,7 @@ function handleArguments(env) {
105
101
if ( path . resolve ( pkgPath ) !== path . normalize ( pkgPath ) ) {
106
102
pkgPath = path . join ( env . configBase , pkgPath ) ;
107
103
}
108
- gutil . log ( 'Verifying plugins in ' + pkgPath ) ;
104
+ log . info ( 'Verifying plugins in ' + pkgPath ) ;
109
105
return getBlacklist ( function ( err , blacklist ) {
110
106
if ( err ) {
111
107
return logBlacklistError ( err ) ;
@@ -118,24 +114,24 @@ function handleArguments(env) {
118
114
}
119
115
120
116
if ( ! env . modulePath ) {
121
- gutil . log (
117
+ log . error (
122
118
chalk . red ( 'Local gulp not found in' ) ,
123
119
chalk . magenta ( tildify ( env . cwd ) )
124
120
) ;
125
- gutil . log ( chalk . red ( 'Try running: npm install gulp' ) ) ;
121
+ log . error ( chalk . red ( 'Try running: npm install gulp' ) ) ;
126
122
exit ( 1 ) ;
127
123
}
128
124
129
125
if ( ! env . configPath ) {
130
- gutil . log ( chalk . red ( 'No gulpfile found' ) ) ;
126
+ log . error ( chalk . red ( 'No gulpfile found' ) ) ;
131
127
exit ( 1 ) ;
132
128
}
133
129
134
130
// Chdir before requiring gulpfile to make sure
135
131
// we let them chdir as needed
136
132
if ( process . cwd ( ) !== env . cwd ) {
137
133
process . chdir ( env . cwd ) ;
138
- gutil . log (
134
+ log . info (
139
135
'Working directory changed to' ,
140
136
chalk . magenta ( tildify ( env . cwd ) )
141
137
) ;
@@ -145,7 +141,7 @@ function handleArguments(env) {
145
141
var range = findRange ( env . modulePackage . version , ranges ) ;
146
142
147
143
if ( ! range ) {
148
- return gutil . log (
144
+ return log . error (
149
145
chalk . red ( 'Unsupported gulp version' , env . modulePackage . version )
150
146
) ;
151
147
}
0 commit comments