Skip to content

Commit 9e15ec7

Browse files
committed
fix: override ui write level
This method is more reliable than using regexes on the input/output streams. Fix #2540
1 parent fbc585b commit 9e15ec7

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

packages/angular-cli/lib/cli/index.js

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,30 @@
22

33
// This file hooks up on require calls to transpile TypeScript.
44
const cli = require('ember-cli/lib/cli');
5+
const UI = require('ember-cli/lib/ui');
56
const path = require('path');
67

78
Error.stackTraceLimit = Infinity;
89

910
module.exports = function(options) {
10-
const oldStdoutWrite = process.stdout.write;
11-
process.stdout.write = function (line) {
12-
line = line.toString();
13-
if (line.match(/version:|WARNING:/)) {
14-
return;
15-
}
16-
if (line.match(/ember-cli-(inject-)?live-reload/)) {
17-
// don't replace 'ember-cli-live-reload' on ng init diffs
18-
return oldStdoutWrite.apply(process.stdout, arguments);
19-
}
20-
line = line.replace(/ember-cli(?!.com)/g, 'angular-cli')
21-
.replace(/\bember\b(?!-cli.com)/g, 'ng');
22-
return oldStdoutWrite.apply(process.stdout, arguments);
23-
};
2411

25-
const oldStderrWrite = process.stderr.write;
26-
process.stderr.write = function (line) {
27-
line = line.toString()
28-
.replace(/ember-cli(?!.com)/g, 'angular-cli')
29-
.replace(/\bember\b(?!-cli.com)/g, 'ng');
30-
return oldStderrWrite.apply(process.stdout, arguments);
12+
// patch UI to assume DEFAULT_WRITE_LEVEL='ERROR'
13+
// this will remove most Ember-CLI specific warnings (which don't apply to Angular-CLI)
14+
UI.prototype.writeLevelVisible = function(writeLevel) {
15+
var levels = this.WRITE_LEVELS;
16+
writeLevel = writeLevel || 'ERROR';
17+
return levels[writeLevel] >= levels['ERROR'];
3118
};
3219

3320
options.cli = {
3421
name: 'ng',
3522
root: path.join(__dirname, '..', '..'),
36-
npmPackage: 'angular-cli'
23+
npmPackage: 'angular-cli',
24+
ui: UI
3725
};
3826

3927
// ensure the environemnt variable for dynamic paths
4028
process.env.PWD = process.env.PWD || process.cwd();
41-
42-
4329
process.env.CLI_ROOT = process.env.CLI_ROOT || path.resolve(__dirname, '..', '..');
4430

4531
return cli(options);

0 commit comments

Comments
 (0)