Skip to content

Commit

Permalink
fix: override ui write level
Browse files Browse the repository at this point in the history
This method is more reliable than using regexes on
the input/output streams.

Fix #2540
  • Loading branch information
filipesilva committed Oct 10, 2016
1 parent fbc585b commit edc14dd
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions packages/angular-cli/lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,30 @@

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

Error.stackTraceLimit = Infinity;

module.exports = function(options) {
const oldStdoutWrite = process.stdout.write;
process.stdout.write = function (line) {
line = line.toString();
if (line.match(/version:|WARNING:/)) {
return;
}
if (line.match(/ember-cli-(inject-)?live-reload/)) {
// don't replace 'ember-cli-live-reload' on ng init diffs
return oldStdoutWrite.apply(process.stdout, arguments);
}
line = line.replace(/ember-cli(?!.com)/g, 'angular-cli')
.replace(/\bember\b(?!-cli.com)/g, 'ng');
return oldStdoutWrite.apply(process.stdout, arguments);
};

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

options.cli = {
name: 'ng',
root: path.join(__dirname, '..', '..'),
npmPackage: 'angular-cli'
npmPackage: 'angular-cli',
ui: UI
};

// ensure the environemnt variable for dynamic paths
process.env.PWD = process.env.PWD || process.cwd();


process.env.CLI_ROOT = process.env.CLI_ROOT || path.resolve(__dirname, '..', '..');

return cli(options);
Expand Down

0 comments on commit edc14dd

Please sign in to comment.