Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): use process TTY as progress default
Browse files Browse the repository at this point in the history
Fix #11195
  • Loading branch information
filipesilva committed Aug 16, 2018
1 parent 73c6135 commit d1387b6
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 10 deletions.
4 changes: 3 additions & 1 deletion packages/angular_devkit/build_angular/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
statsToString,
statsWarningsToString,
} from '../angular-cli-files/utilities/stats';
import { normalizeAssetPatterns, normalizeFileReplacements } from '../utils';
import { defaultProgress, normalizeAssetPatterns, normalizeFileReplacements } from '../utils';
import { AssetPatternObject, BrowserBuilderSchema, CurrentFileReplacement } from './schema';
const webpackMerge = require('webpack-merge');

Expand Down Expand Up @@ -138,6 +138,8 @@ export class BrowserBuilder implements Builder<BrowserBuilderSchema> {
supportES2015,
};

wco.buildOptions.progress = defaultProgress(wco.buildOptions.progress);

const webpackConfigs: {}[] = [
getCommonConfig(wco),
getBrowserConfig(wco),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface BrowserBuilderSchema {
/**
* Log progress to the console while building.
*/
progress: boolean;
progress?: boolean;

/**
* Localization file to use for i18n.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@
},
"progress": {
"type": "boolean",
"description": "Log progress to the console while building.",
"default": true
"description": "Log progress to the console while building."
},
"i18nFile": {
"type": "string",
Expand Down
4 changes: 3 additions & 1 deletion packages/angular_devkit/build_angular/src/karma/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { readTsconfig } from '../angular-cli-files/utilities/read-tsconfig';
import { requireProjectModule } from '../angular-cli-files/utilities/require-project-module';
import { AssetPatternObject, CurrentFileReplacement } from '../browser/schema';
import { normalizeAssetPatterns, normalizeFileReplacements } from '../utils';
import { defaultProgress, normalizeAssetPatterns, normalizeFileReplacements } from '../utils';
import { KarmaBuilderSchema } from './schema';
const webpackMerge = require('webpack-merge');

Expand Down Expand Up @@ -137,6 +137,8 @@ export class KarmaBuilder implements Builder<KarmaBuilderSchema> {
supportES2015,
};

wco.buildOptions.progress = defaultProgress(wco.buildOptions.progress);

const webpackConfigs: {}[] = [
getCommonConfig(wco),
getStylesConfig(wco),
Expand Down
3 changes: 1 addition & 2 deletions packages/angular_devkit/build_angular/src/karma/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@
},
"progress": {
"type": "boolean",
"description": "Log progress to the console while building.",
"default": true
"description": "Log progress to the console while building."
},
"watch": {
"type": "boolean",
Expand Down
4 changes: 3 additions & 1 deletion packages/angular_devkit/build_angular/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import { readTsconfig } from '../angular-cli-files/utilities/read-tsconfig';
import { requireProjectModule } from '../angular-cli-files/utilities/require-project-module';
import { getBrowserLoggingCb } from '../browser';
import { normalizeFileReplacements } from '../utils';
import { defaultProgress, normalizeFileReplacements } from '../utils';
import { BuildWebpackServerSchema } from './schema';
const webpackMerge = require('webpack-merge');

Expand Down Expand Up @@ -98,6 +98,8 @@ export class ServerBuilder implements Builder<BuildWebpackServerSchema> {
supportES2015,
};

wco.buildOptions.progress = defaultProgress(wco.buildOptions.progress);

const webpackConfigs: {}[] = [
getCommonConfig(wco),
getServerConfig(wco),
Expand Down
3 changes: 1 addition & 2 deletions packages/angular_devkit/build_angular/src/server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
},
"progress": {
"type": "boolean",
"description": "Log progress to the console while building.",
"default": true
"description": "Log progress to the console while building."
},
"i18nFile": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

export function defaultProgress(progress: boolean | undefined): boolean {
if (progress === undefined) {
return process.stdout.isTTY === true;
}

return progress;
}
1 change: 1 addition & 0 deletions packages/angular_devkit/build_angular/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

export * from './default-progress';
export * from './run-module-as-observable-fork';
export * from './normalize-file-replacements';
export * from './normalize-asset-patterns';

0 comments on commit d1387b6

Please sign in to comment.