Skip to content

Don't print progress in a non-TTY context #8148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mgol opened this issue Oct 23, 2017 · 6 comments · Fixed by #8501 or #8925
Closed

Don't print progress in a non-TTY context #8148

mgol opened this issue Oct 23, 2017 · 6 comments · Fixed by #8501 or #8925
Assignees
Labels
effort1: easy (hours) feature Issue that requests a new feature help wanted P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@mgol
Copy link
Member

mgol commented Oct 23, 2017

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Versions.

@angular/cli: 1.4.5
node: 8.7.0
os: darwin x64
@angular/common: 4.4.4
@angular/compiler: 4.4.4
@angular/core: 4.4.4
@angular/forms: 4.4.4
@angular/http: 4.4.4
@angular/platform-browser: 4.4.4
@angular/platform-browser-dynamic: 4.4.4
@angular/router: 4.4.4
@angular/cli: 1.4.5
@angular/compiler-cli: 4.4.4
typescript: 2.3.4

Repro steps.

Run ng build --prod --aot in a CI environment like Travis CI or GitLab CI. You'll see something like:

0% compiling 10% building modules 0/1 modules 1 active project/src/main.ts 10% building modules 1/1 modules 0 active 10% building modules 1/2 modules 1 active project/src/polyfills.ts 10% building modules 2/2 modules 0 active 10% building modules 2/3 modules 1 active project/src/styles.scss 10% building modules 3/3 modules 0 active 10% building modules 3/4 modules 1 active project/src/styles.scss 10% building modules 4/4 modules 0 active 10% building modules 4/5 modules 1 active ...de_modules/css-loader/lib/css-base.js 10% building modules 5/5 modules 0 active 10% building modules 5/6 modules 1 active project/src/main.ts 10% building modules 5/7 modules 2 active project/src/polyfills.ts 10% building modules 6/7 modules 1 active project/src/polyfills.ts 10% building modules 7/7 modules 0 active 10% building modules 7/8 modules 1 active project/src/environments/environment.ts 10% building modules 8/8 modules 0 active 10% building modules 8/9 modules 1 active ...$$_gendir/app/app.module.ngfactory.ts 11% building modules 9/9 modules 0 active 11% building modules 9/10 modules 1 active project/src/app/app.module.ts 11% building modules 10/10 modules 0 active 11% building modules 10/11 modules 1 active project/src/app/app.component.ts 11% building modules 11/11 modules 0 active 11% building modules 11/12 modules 1 active ...gendir/app/app.component.ngfactory.ts

This can be alleviated by passing the --no-progress flag to ng build but it introduces a mental burden to add that to every command invoked on CI. If you have many such commands or if they're deeply nested in npm scripts this may require duplicating a lot of code.

The log given by the failure.

N/A

Desired functionality.

Angular CLI should not print progress when run in a non-TTY environment. Optionally it could switch its reporter to something like dots that only appends a dot when something happens and doesn't try to rewrite the output, printing a lot of noise.

Mention any other details that might be useful.

Node.js has an API for this exact purpose: process.stdout.isTTY, see https://nodejs.org/api/tty.html

@filipesilva filipesilva assigned Brocco and filipesilva and unassigned Brocco Oct 25, 2017
@filipesilva filipesilva added effort1: easy (hours) help wanted P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent feature Issue that requests a new feature labels Oct 25, 2017
@filipesilva
Copy link
Contributor

I agree that we should use the API to determine the system default. Would be really helpful.

devoto13 added a commit to devoto13/angular-cli that referenced this issue Oct 26, 2017
The default value is changed from `true` to `progress.stdout.isTTY`. It
still has lower priority than value specified by command line flag or in
the .angular-cli.json config.

Fixes angular#8148
devoto13 added a commit to devoto13/angular-cli that referenced this issue Nov 15, 2017
The default value is changed from `true` to `progress.stdout.isTTY`. It
still has lower priority than value specified by command line flag or in
the .angular-cli.json config.

Fixes angular#8148
devoto13 added a commit to devoto13/angular-cli that referenced this issue Nov 17, 2017
The default value is changed from `true` to `progress.stdout.isTTY`. It
still has lower priority than value specified by command line flag or in
the .angular-cli.json config.

Fixes angular#8148
hansl pushed a commit that referenced this issue Nov 21, 2017
The default value is changed from `true` to `progress.stdout.isTTY`. It
still has lower priority than value specified by command line flag or in
the .angular-cli.json config.

Fixes #8148
@mgol
Copy link
Member Author

mgol commented Dec 14, 2017

Something still doesn't work here. In Karma tests run via WebStorm process.stdout.isTTY === undefined (I checked) and yet the progress is printed, flooding the console. The same happens to me in GitLab CI. Angular CLI 1.6.0.

@devoto13
Copy link
Contributor

devoto13 commented Dec 14, 2017

@mgol I don't use GitLab CI, so don't know why it does not work there.

Regarding WebStorm: my PR only changes the default for the --progress flag of the ng test command. So if you use Karma run configuration in WebStorm it will still print progress, because WebStorm runs Karma directly and not using ng test command. I think we should also update here - change from true to process.stdout.isTTY === true, so this feature will also work when running Karma directly. Can you submit a PR?

@mgol
Copy link
Member Author

mgol commented Dec 14, 2017

@devoto13 OK, thanks, I know what's happening now.

In GitLab CI process.stdout.isTTY === undefined as well, the progress I'm seeing comes from building the universal app according to the Universal CLI story i.e. via:

webpack --config webpack.server.config.js --progress --colors

That's a Webpack thing, not CLI one, though so here what's needed is mostly the Karma modification. I'll see what I can do.

devoto13 added a commit to devoto13/angular-cli that referenced this issue Dec 18, 2017
…de TTY

Fixes a shortcoming of angular#8501. Apply same logic for setting --progress
flat when running Karma directly (as opposed to running it using
`ng test` command).

Fixes angular#8148
devoto13 added a commit to devoto13/angular-cli that referenced this issue Dec 18, 2017
…de TTY

Fixes a shortcoming of angular#8501. Apply same logic for setting --progress
flag when running Karma directly (as opposed to running it using
`ng test` command).

Fixes angular#8148
hansl pushed a commit that referenced this issue Dec 19, 2017
…de TTY

Fixes a shortcoming of #8501. Apply same logic for setting --progress
flag when running Karma directly (as opposed to running it using
`ng test` command).

Fixes #8148
hansl pushed a commit that referenced this issue Dec 21, 2017
…de TTY

Fixes a shortcoming of #8501. Apply same logic for setting --progress
flag when running Karma directly (as opposed to running it using
`ng test` command).

Fixes #8148
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
The default value is changed from `true` to `progress.stdout.isTTY`. It
still has lower priority than value specified by command line flag or in
the .angular-cli.json config.

Fixes angular#8148
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
…de TTY

Fixes a shortcoming of angular#8501. Apply same logic for setting --progress
flag when running Karma directly (as opposed to running it using
`ng test` command).

Fixes angular#8148
@mgol
Copy link
Member Author

mgol commented Jun 11, 2018

This has regressed in CLI 6, see a new bug report: #11195.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: easy (hours) feature Issue that requests a new feature help wanted P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
4 participants