Skip to content

Commit 0127fcc

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

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,25 @@
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);
31-
};
12+
// patch UI to not print Ember-CLI warnings (which don't apply to Angular-CLI)
13+
UI.prototype.writeWarnLine = function () { }
3214

3315
options.cli = {
3416
name: 'ng',
3517
root: path.join(__dirname, '..', '..'),
36-
npmPackage: 'angular-cli'
18+
npmPackage: 'angular-cli',
19+
ui: UI
3720
};
3821

3922
// ensure the environemnt variable for dynamic paths
4023
process.env.PWD = process.env.PWD || process.cwd();
41-
42-
4324
process.env.CLI_ROOT = process.env.CLI_ROOT || path.resolve(__dirname, '..', '..');
4425

4526
return cli(options);

0 commit comments

Comments
 (0)