Skip to content

Commit

Permalink
Fix: Log requireFail results in yellow on stdout instead of red on st…
Browse files Browse the repository at this point in the history
…derr (fixes #142) (#151)
  • Loading branch information
phated authored and sttk committed Jan 24, 2018
1 parent cd2e159 commit e9af812
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cli.on('require', function(name) {
});

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

cli.on('respawn', function(flags, child) {
Expand Down
1 change: 1 addition & 0 deletions lib/shared/ansi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
gray: hasColors ? colors.gray : noColor,
bgred: hasColors ? colors.bgred : noColor,
bold: hasColors ? colors.bold : noColor,
yellow: hasColors ? colors.yellow : noColor,
};

function noColor(message) {
Expand Down
8 changes: 4 additions & 4 deletions test/exports-as-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ describe('exports as tasks', function() {
'--gulpfile ./test/fixtures/gulpfiles/gulpfile-exports.babel.js')
.run(cb);

function cb(err, stdout) {
function cb(err, stdout, stderr) {
expect(err).toEqual(null);
// Skipping stderr expectation because babel broke node 0.10
// expect(stderr).toEqual('');
expect(stderr).toEqual('');
var filepath = path.join(expectedDir, 'tasks-as-exports.txt');
var expected = fs.readFileSync(filepath, 'utf-8');
stdout = eraseTime(skipLines(stdout, 2));
// Remove babel/register lines
stdout = eraseTime(skipLines(stdout, 3));
expect(stdout).toEqual(expected);
done(err);
}
Expand Down
14 changes: 6 additions & 8 deletions test/flags-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,26 @@ describe('flag: --require', function() {
}
});

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

function cb(err, stdout, stderr) {
expect(err).toEqual(null);
stderr = eraseLapse(eraseTime(stderr));
expect(stderr).toMatch('Failed to load external module ./null-module.js');
expect(stderr).toEqual('');
stdout = eraseLapse(eraseTime(stdout));
expect(stdout).toMatch('Failed to load external module ./null-module.js');
expect(stdout).toNotMatch('inside test module');
expect(stdout).toNotMatch(
'Requiring external module ../test-module.js');

var chgWorkdirLog = headLines(stdout, 1);
var chgWorkdirLog = headLines(stdout, 2);
var workdir = 'test/fixtures/gulpfiles'.replace(/\//g, path.sep);
expect(chgWorkdirLog).toMatch('Working directory changed to ');
expect(chgWorkdirLog).toMatch(workdir);

stdout = eraseLapse(eraseTime(skipLines(stdout, 2)));
stdout = eraseLapse(eraseTime(skipLines(stdout, 3)));
expect(stdout).toEqual(
'Starting \'default\'...\n' +
'Starting \'test1\'...\n' +
Expand All @@ -85,9 +86,6 @@ describe('flag: --require', function() {
''
);

stderr = eraseTime(stderr);
expect(stderr).toEqual(
'Failed to load external module ./null-module.js\n');
done(err);
}
});
Expand Down

0 comments on commit e9af812

Please sign in to comment.