fix: errors from tns doctor
are not visible in CI environment
#4404
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
tns doctor
detects errors in the configuration, it should print them to stdout and prompt the user to select how to resolve them.In non-interactive terminal, it should just print the errors and fails as the prompter are not meaningful in non-interactive terminal - there's noone to answer them.
The logic works fine when you pipe the output of
tns doctor
to file for example (tns doctor > out.txt
). CLI correctly detects the terminal as non-interactive, prints the errors and exits.However, most of the CI environments are determined as interactive terminals by CLI. That's because CLI checks if the stdout and stdin of the current process are text terminal (TTY). CI environments set required flags, so the process seems like running in such text terminal.
When CLI thinks the process is running in text terminal, it uses some external package (ora) to print pretty lines. However,
ora
package also checks if the process is running in text terminal (which both CLI andora
think is true), but it also checks if the environment variableCI
is set.When it is set,
ora
package decides that it cannot print colored messages and just doesn't print anything.To resolve this, improve the check if interactive terminal in CLI to respect the known environment variables that define the process as running in CI:
CI
is set.CI
is setJENKINS_HOME
is setWhenever one of those environment variables is set, CLI will decide it is running in non-interactive terminal and will not use
ora
(fortns doctor
). It will also not show any prompters in this case.PR Checklist
What is the current behavior?
Errors from
tns doctor
are not shown in Travis/CircleCI. Instead the CI build just hangs as CLI had shown prompter.What is the new behavior?
Errors from
tns doctor
are shown in Travis/CircleCI and the CI Build fails directly instead of hanging.Fixes issue #4383