Skip to content
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

Merged
merged 4 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
}

if (cmds.length) {
// propagate YARN_SILENT env variable to executed commands
process.env.YARN_SILENT = '1';
// Disable wrapper in executed commands
process.env.YARN_WRAP_OUTPUT = 'false';
Copy link
Member

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.

for (const [stage, cmd] of cmds) {
// only tack on trailing arguments for default script, ignore for pre and post - #1595
const cmdWithArgs = stage === action ? sh`${unquoted(cmd)} ${args}` : cmd;
Expand Down
15 changes: 12 additions & 3 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ function findProjectRoot(base: string): string {

const boolify = val => val.toString().toLowerCase() !== 'false' && val !== '0';

function boolifyWithDefault(val: any, defaultResult: boolean): boolean {
if (val === undefined || val === null || val === '') {
return defaultResult;
} else {
return boolify(val);
}
}

export function main({
startArgs,
args,
Expand Down Expand Up @@ -207,9 +215,10 @@ export function main({
reporter.initPeakMemoryCounter();

const config = new Config(reporter);
const outputWrapper = !commander.json && command.hasWrapper(commander, commander.args);
const outputWrapperEnabled = boolifyWithDefault(process.env.YARN_WRAP_OUTPUT, true);
const shouldWrapOutput = outputWrapperEnabled && !commander.json && command.hasWrapper(commander, commander.args);

if (outputWrapper) {
if (shouldWrapOutput) {
reporter.header(commandName, {name: 'yarn', version});
}

Expand Down Expand Up @@ -243,7 +252,7 @@ export function main({
}

return command.run(config, reporter, commander, commander.args).then(exitCode => {
if (outputWrapper) {
if (shouldWrapOutput) {
reporter.footer(false);
}
return exitCode;
Expand Down