-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat(cli): Disable only header/footer in nested commands, not all output #4811
Conversation
This is done instead of disabling all output, which was a bit too much (see issue #4615).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very simple and elegant solution, I love it.
Added a comment to make the detection and code a bit better. Will merge after you address that.
Thanks!
src/cli/index.js
Outdated
@@ -207,7 +207,8 @@ export function main({ | |||
reporter.initPeakMemoryCounter(); | |||
|
|||
const config = new Config(reporter); | |||
const outputWrapper = !commander.json && command.hasWrapper(commander, commander.args); | |||
const outputWrapperEnv = process.env.YARN_WRAPOUTPUT === undefined || process.env.YARN_WRAPOUTPUT == '1'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go with the following:
const disableOutputWrapper = process.env.YARN_WRAPOUTPUT === '0' || process.env.YARN_WRAPOUTPUT === 'false';
const shouldWrapOutput = !disableOutputWrapper && !commander.json && command.hasWrapper(commander, commander.args);
if (shouldWrapOutput) {
This change will increase the build size from 9.94 MB to 9.94 MB, an increase of 448 bytes (0%)
|
I moved the boolification of the environment variable into a separate function. This function can then also be used for other variables, like The functionality of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the refactoring, thanks a lot!
// propagate YARN_SILENT env variable to executed commands | ||
process.env.YARN_SILENT = '1'; | ||
// Disable wrapper in executed commands | ||
process.env.YARN_WRAP_OUTPUT = 'false'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: do not mutate process.env
in any way.
Many thanks for this! :-) |
**Summary** Use `boolifyWithDefault()` to determine if environment variable values are `true` or `false`. This ensures that all environment variables interpret the same values the same way. This changes the behavior of `YARN_SILENT` and `YARN_IGNORE_PATH` if they have "unexpected" values, all nonempty stings beside `"0"` and `"false"` are now interpreted as `true`. For example `YARN_SILENT=hello` was interpreted as `false` before, now it is `true`. This makes some sense since those values are truthy in Javascript, but generally makes things more predictable if it works like that for all yarn environment variables. `YARN_SILENT=true` was also interpreted as `false`. This now definitely makes more sense since it will be interpreted as `true`. See also [#4811](#4811 (comment)). **Test plan** There should be no change to the existing intended functionality and the existing tests still pass.
**Summary** Tests started failing on Travis after #4811, somewhat randomly, due to the mexpecting the unwrapped output. This PR fixes those expectations and moves normalize-manifest tests to snapshots since that's easier than updating 40+ JSON files by hand. **Test plan** Tests should pass on all platforms and CI and locally.
**Summary** Tests started failing on Travis after #4811, somewhat randomly, due to them expecting the unwrapped output. This PR fixes those expectations and moves normalize-manifest tests to snapshots since that's easier than updating 40+ JSON files by hand. **Test plan** Tests should pass on all platforms and CI and locally.
…put (yarnpkg#4811) **Summary** Fixes yarnpkg#4615. Disabling all Yarn output in nested commands with `YARN_SILENT` is a bit much, we usually want to see the output. This pull request introduces a new environment variable `YARN_WRAP_OUTPUT` that can be set to `0` to disable the header and footer Yarn normally displays. Disabling the header/footer might also be useful in other situations, like other tools calling Yarn, so the `YARN_WRAP_OUTPUT` variable has general use. **Test plan** Existing integration tests.
…npkg#4823) **Summary** Use `boolifyWithDefault()` to determine if environment variable values are `true` or `false`. This ensures that all environment variables interpret the same values the same way. This changes the behavior of `YARN_SILENT` and `YARN_IGNORE_PATH` if they have "unexpected" values, all nonempty stings beside `"0"` and `"false"` are now interpreted as `true`. For example `YARN_SILENT=hello` was interpreted as `false` before, now it is `true`. This makes some sense since those values are truthy in Javascript, but generally makes things more predictable if it works like that for all yarn environment variables. `YARN_SILENT=true` was also interpreted as `false`. This now definitely makes more sense since it will be interpreted as `true`. See also [yarnpkg#4811](yarnpkg#4811 (comment)). **Test plan** There should be no change to the existing intended functionality and the existing tests still pass.
…pkg#4852) **Summary** Tests started failing on Travis after yarnpkg#4811, somewhat randomly, due to them expecting the unwrapped output. This PR fixes those expectations and moves normalize-manifest tests to snapshots since that's easier than updating 40+ JSON files by hand. **Test plan** Tests should pass on all platforms and CI and locally.
Summary
Fixes #4615. Disabling all Yarn output in nested commands with
YARN_SILENT
is a bit much, we usually want to see the output. This pull request introduces a new environment variableYARN_WRAP_OUTPUT
that can be set to0
to disable the header and footer Yarn normally displays.Disabling the header/footer might also be useful in other situations, like other tools calling Yarn, so the
YARN_WRAP_OUTPUT
variable has general use.Test plan
Existing integration tests.