From 3d7854c2cc90c9d87e1cf89f040a806e11e101ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= <5175937+theofidry@users.noreply.github.com> Date: Sat, 14 Oct 2023 00:10:57 +0200 Subject: [PATCH] fix: Get the raw output for the Composer version (#1063) I suspect in some context the current `ComposerOrchestrator::getVersion()` could get the ANSI output for which the regex we use afterwards to extract the Composer version does not work. Rather than fixing the regex which is not trivial, it makes more sense to guarantee a no-ANSI output. Fixes #1004. --- src/Composer/ComposerOrchestrator.php | 2 +- tests/Console/Command/CompileTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/ComposerOrchestrator.php b/src/Composer/ComposerOrchestrator.php index 10f84fc0d..c12b59cf7 100644 --- a/src/Composer/ComposerOrchestrator.php +++ b/src/Composer/ComposerOrchestrator.php @@ -75,7 +75,7 @@ public static function getVersion( $logger = new CompilerLogger($io ?? IO::createNull()); $composerExecutable = $composerBin ?? self::retrieveComposerExecutable(); - $getVersionProcess = new Process([$composerExecutable, '--version']); + $getVersionProcess = new Process([$composerExecutable, '--version', '--no-ansi']); $logger->log( CompilerLogger::CHEVRON_PREFIX, diff --git a/tests/Console/Command/CompileTest.php b/tests/Console/Command/CompileTest.php index dce69f130..7afba068a 100644 --- a/tests/Console/Command/CompileTest.php +++ b/tests/Console/Command/CompileTest.php @@ -858,7 +858,7 @@ public function test_it_can_build_a_phar_file_in_verbose_mode(): void ? Removing the existing PHAR "/path/to/tmp/test.phar" ? Checking Composer compatibility - > '/usr/local/bin/composer' '--version' + > '/usr/local/bin/composer' '--version' '--no-ansi' > 2.5.0 (Box requires ^2.2.0) > Supported version detected ? Registering compactors @@ -986,7 +986,7 @@ public function test_it_can_build_a_phar_file_in_very_verbose_mode(): void ? Removing the existing PHAR "/path/to/tmp/test.phar" ? Checking Composer compatibility - > '/usr/local/bin/composer' '--version' + > '/usr/local/bin/composer' '--version' '--no-ansi' > 2.5.0 (Box requires ^2.2.0) > Supported version detected ? Registering compactors