From 2a2f0bc20edd1c21144ca52aabaa6e9a9874dfe8 Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Sat, 3 Feb 2024 01:49:25 -0500 Subject: [PATCH] [make:*] fix bundled php-cs-fixer not working on windows --- src/Util/TemplateLinter.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Util/TemplateLinter.php b/src/Util/TemplateLinter.php index 74707ef07..92245d8ab 100644 --- a/src/Util/TemplateLinter.php +++ b/src/Util/TemplateLinter.php @@ -56,12 +56,21 @@ public function lintPhpTemplate(string|array $templateFilePath): void $templateFilePath = [$templateFilePath]; } - foreach ($templateFilePath as $filePath) { - $cmdPrefix = $this->needsPhpCmdPrefix ? 'php ' : ''; + $ignoreEnv = str_contains(strtolower(\PHP_OS), 'win') ? 'set PHP_CS_FIXER_IGNORE_ENV=1&' : 'PHP_CS_FIXER_IGNORE_ENV=1 '; - $process = Process::fromShellCommandline(sprintf('PHP_CS_FIXER_IGNORE_ENV=1 %s%s --config=%s --using-cache=no fix %s', $cmdPrefix, $this->phpCsFixerBinaryPath, $this->phpCsFixerConfigPath, $filePath)); + $cmdPrefix = $this->needsPhpCmdPrefix ? 'php ' : ''; - $process->run(); + foreach ($templateFilePath as $filePath) { + Process::fromShellCommandline(sprintf( + '%s%s%s --config=%s --using-cache=no fix %s', + $ignoreEnv, + $cmdPrefix, + $this->phpCsFixerBinaryPath, + $this->phpCsFixerConfigPath, + $filePath + )) + ->run() + ; } }