Skip to content

Commit e9af812

Browse files
phatedsttk
authored andcommitted
Fix: Log requireFail results in yellow on stdout instead of red on stderr (fixes #142) (#151)
1 parent cd2e159 commit e9af812

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ cli.on('require', function(name) {
6969
});
7070

7171
cli.on('requireFail', function(name) {
72-
log.error(ansi.red('Failed to load external module'), ansi.magenta(name));
72+
log.warn(ansi.yellow('Failed to load external module'), ansi.magenta(name));
7373
});
7474

7575
cli.on('respawn', function(flags, child) {

lib/shared/ansi.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
gray: hasColors ? colors.gray : noColor,
1616
bgred: hasColors ? colors.bgred : noColor,
1717
bold: hasColors ? colors.bold : noColor,
18+
yellow: hasColors ? colors.yellow : noColor,
1819
};
1920

2021
function noColor(message) {

test/exports-as-tasks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ describe('exports as tasks', function() {
1919
'--gulpfile ./test/fixtures/gulpfiles/gulpfile-exports.babel.js')
2020
.run(cb);
2121

22-
function cb(err, stdout) {
22+
function cb(err, stdout, stderr) {
2323
expect(err).toEqual(null);
24-
// Skipping stderr expectation because babel broke node 0.10
25-
// expect(stderr).toEqual('');
24+
expect(stderr).toEqual('');
2625
var filepath = path.join(expectedDir, 'tasks-as-exports.txt');
2726
var expected = fs.readFileSync(filepath, 'utf-8');
28-
stdout = eraseTime(skipLines(stdout, 2));
27+
// Remove babel/register lines
28+
stdout = eraseTime(skipLines(stdout, 3));
2929
expect(stdout).toEqual(expected);
3030
done(err);
3131
}

test/flags-require.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,26 @@ describe('flag: --require', function() {
5050
}
5151
});
5252

53-
it('errors if module doesn\'t exist', function(done) {
53+
it('warns if module doesn\'t exist', function(done) {
5454
runner({ verbose: false })
5555
.gulp('--require ./null-module.js', '--cwd ./test/fixtures/gulpfiles')
5656
.run(cb);
5757

5858
function cb(err, stdout, stderr) {
5959
expect(err).toEqual(null);
60-
stderr = eraseLapse(eraseTime(stderr));
61-
expect(stderr).toMatch('Failed to load external module ./null-module.js');
60+
expect(stderr).toEqual('');
61+
stdout = eraseLapse(eraseTime(stdout));
62+
expect(stdout).toMatch('Failed to load external module ./null-module.js');
6263
expect(stdout).toNotMatch('inside test module');
6364
expect(stdout).toNotMatch(
6465
'Requiring external module ../test-module.js');
6566

66-
var chgWorkdirLog = headLines(stdout, 1);
67+
var chgWorkdirLog = headLines(stdout, 2);
6768
var workdir = 'test/fixtures/gulpfiles'.replace(/\//g, path.sep);
6869
expect(chgWorkdirLog).toMatch('Working directory changed to ');
6970
expect(chgWorkdirLog).toMatch(workdir);
7071

71-
stdout = eraseLapse(eraseTime(skipLines(stdout, 2)));
72+
stdout = eraseLapse(eraseTime(skipLines(stdout, 3)));
7273
expect(stdout).toEqual(
7374
'Starting \'default\'...\n' +
7475
'Starting \'test1\'...\n' +
@@ -85,9 +86,6 @@ describe('flag: --require', function() {
8586
''
8687
);
8788

88-
stderr = eraseTime(stderr);
89-
expect(stderr).toEqual(
90-
'Failed to load external module ./null-module.js\n');
9189
done(err);
9290
}
9391
});

0 commit comments

Comments
 (0)