Skip to content
Merged
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
13 changes: 12 additions & 1 deletion src/Composer/ComposerProcessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use RuntimeException;
use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Process\Process;
use const PHP_OS_FAMILY;

/**
* @final
Expand Down Expand Up @@ -153,12 +154,22 @@ private static function getDefaultEnvVars(): array
private static function retrieveComposerExecutable(): string
{
$executableFinder = new ExecutableFinder();
$executableFinder->addSuffix('.phar');

if (self::isWindows()) {
$executableFinder->setSuffixes(['.exe', '.bat', '.cmd', '.com']);
} else {
$executableFinder->addSuffix('.phar');
}

if (null === $composer = $executableFinder->find('composer')) {
throw new RuntimeException('Could not find a Composer executable.');
}

return $composer;
}

private static function isWindows(): bool
{
return PHP_OS_FAMILY !== 'Windows';
}
}
Loading