From 0500e64f8826e73fc3a744c1b01d61f9547d1e1d Mon Sep 17 00:00:00 2001 From: David Szkiba Date: Sun, 25 Aug 2019 17:00:25 +0200 Subject: [PATCH] Respect COMPOSER_NO_INTERATION for search prompt. As described in GH-8289, if no `composer.json` file is found in the current directory, the user is prompted if she wants to use another `composer.json` file from a parent directory even if the `COMPOSER_NO_INTERACTION` environment variable is set. This is fixed here by just moving the check of the environment variable up in the code so that it is evaluated before the user is prompted. --- src/Composer/Console/Application.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index d7d113492..171f4fc5b 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -113,6 +113,10 @@ class Application extends BaseApplication { $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins'); + if (getenv('COMPOSER_NO_INTERACTION')) { + $input->setInteractive(false); + } + $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array( new QuestionHelper(), ))); @@ -208,10 +212,6 @@ class Application extends BaseApplication $io->writeError(sprintf('Warning: This development build of composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.', $_SERVER['PHP_SELF'])); } - if (getenv('COMPOSER_NO_INTERACTION')) { - $input->setInteractive(false); - } - if (!Platform::isWindows() && function_exists('exec') && !getenv('COMPOSER_ALLOW_SUPERUSER')) { if (function_exists('posix_getuid') && posix_getuid() === 0) { if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {