diff --git a/src/cli/commands/run.js b/src/cli/commands/run.js index f3c941ae65..e18d033c15 100644 --- a/src/cli/commands/run.js +++ b/src/cli/commands/run.js @@ -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'; 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; diff --git a/src/cli/index.js b/src/cli/index.js index b9b076e998..53627b0f06 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -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, @@ -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}); } @@ -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;