Skip to content

Commit f7d8333

Browse files
committed
use chalk directly
1 parent f91719b commit f7d8333

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

bin/gulp.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
'use strict';
44
var gutil = require('gulp-util');
55
var prettyTime = require('pretty-hrtime');
6+
var chalk = require('chalk');
67
var semver = require('semver');
78
var archy = require('archy');
89
var Liftoff = require('liftoff');
@@ -14,11 +15,11 @@ var cli = new Liftoff({
1415
});
1516

1617
cli.on('require', function (name) {
17-
gutil.log('Requiring external module', gutil.colors.magenta(name));
18+
gutil.log('Requiring external module', chalk.magenta(name));
1819
});
1920

2021
cli.on('requireFail', function (name) {
21-
gutil.log(gutil.colors.red('Failed to load external module'), gutil.colors.magenta(name));
22+
gutil.log(chalk.red('Failed to load external module'), chalk.magenta(name));
2223
});
2324

2425
cli.launch(handleArguments);
@@ -41,32 +42,32 @@ function handleArguments(env) {
4142
}
4243

4344
if (!env.modulePath) {
44-
gutil.log(gutil.colors.red('No local gulp install found in'), gutil.colors.magenta(env.cwd));
45-
gutil.log(gutil.colors.red('Try running: npm install gulp'));
45+
gutil.log(chalk.red('No local gulp install found in'), chalk.magenta(env.cwd));
46+
gutil.log(chalk.red('Try running: npm install gulp'));
4647
process.exit(1);
4748
}
4849

4950
if (!env.configPath) {
50-
gutil.log(gutil.colors.red('No gulpfile found'));
51+
gutil.log(chalk.red('No gulpfile found'));
5152
process.exit(1);
5253
}
5354

5455
// check for semver difference between cli and local installation
5556
if (semver.gt(cliPackage.version, env.modulePackage.version)) {
56-
gutil.log(gutil.colors.red('Warning: gulp version mismatch:'));
57-
gutil.log(gutil.colors.red('Running gulp is', cliPackage.version));
58-
gutil.log(gutil.colors.red('Local gulp (installed in gulpfile dir) is', env.modulePackage.version));
57+
gutil.log(chalk.red('Warning: gulp version mismatch:'));
58+
gutil.log(chalk.red('Running gulp is', cliPackage.version));
59+
gutil.log(chalk.red('Local gulp (installed in gulpfile dir) is', env.modulePackage.version));
5960
}
6061

6162
var gulpFile = require(env.configPath);
62-
gutil.log('Using gulpfile', gutil.colors.magenta(env.configPath));
63+
gutil.log('Using gulpfile', chalk.magenta(env.configPath));
6364

6465
var gulpInst = require(env.modulePath);
6566
logEvents(gulpInst);
6667

6768
if (process.cwd() !== env.cwd) {
6869
process.chdir(env.cwd);
69-
gutil.log('Working directory changed to', gutil.colors.magenta(env.cwd));
70+
gutil.log('Working directory changed to', chalk.magenta(env.cwd));
7071
}
7172

7273
process.nextTick(function () {
@@ -79,7 +80,7 @@ function handleArguments(env) {
7980

8081
function logTasks(gulpFile, localGulp) {
8182
var tree = taskTree(localGulp.tasks);
82-
tree.label = 'Tasks for ' + gutil.colors.magenta(gulpFile);
83+
tree.label = 'Tasks for ' + chalk.magenta(gulpFile);
8384
archy(tree).split('\n').forEach(function (v) {
8485
if (v.trim().length === 0) return;
8586
gutil.log(v);
@@ -96,22 +97,22 @@ function formatError(e) {
9697
// wire up logging events
9798
function logEvents(gulpInst) {
9899
gulpInst.on('task_start', function (e) {
99-
gutil.log('Starting', "'" + gutil.colors.cyan(e.task) + "'...");
100+
gutil.log('Starting', "'" + chalk.cyan(e.task) + "'...");
100101
});
101102

102103
gulpInst.on('task_stop', function (e) {
103104
var time = prettyTime(e.hrDuration);
104-
gutil.log('Finished', "'" + gutil.colors.cyan(e.task) + "'", 'after', gutil.colors.magenta(time));
105+
gutil.log('Finished', "'" + chalk.cyan(e.task) + "'", 'after', chalk.magenta(time));
105106
});
106107

107108
gulpInst.on('task_err', function (e) {
108109
var msg = formatError(e);
109110
var time = prettyTime(e.hrDuration);
110-
gutil.log("'" + gutil.colors.cyan(e.task) + "'", 'errored after', gutil.colors.magenta(time), gutil.colors.red(msg));
111+
gutil.log("'" + chalk.cyan(e.task) + "'", 'errored after', chalk.magenta(time), chalk.red(msg));
111112
});
112113

113114
gulpInst.on('task_not_found', function (err) {
114-
gutil.log(gutil.colors.red("Task '" + err.task + "' was not defined in your gulpfile but you tried to run it."));
115+
gutil.log(chalk.red("Task '" + err.task + "' was not defined in your gulpfile but you tried to run it."));
115116
gutil.log('Please check the documentation for proper gulpfile formatting.');
116117
process.exit(1);
117118
});

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"semver": "^2.2.1",
3131
"archy": "^0.0.2",
3232
"deprecated": "^0.0.1",
33-
"liftoff": "^0.8.7"
33+
"liftoff": "^0.8.7",
34+
"chalk": "^0.4.0"
3435
},
3536
"devDependencies": {
3637
"mocha": "^1.17.0",

0 commit comments

Comments
 (0)