Fix detection of the root package version to always use the correct cwd
parent
e87190e3da
commit
1fca6be3bf
|
@ -275,7 +275,7 @@ class Factory
|
||||||
$parser = new VersionParser;
|
$parser = new VersionParser;
|
||||||
$guesser = new VersionGuesser($config, new ProcessExecutor($io), $parser);
|
$guesser = new VersionGuesser($config, new ProcessExecutor($io), $parser);
|
||||||
$loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser);
|
$loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser);
|
||||||
$package = $loader->load($localConfig);
|
$package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
|
||||||
$composer->setPackage($package);
|
$composer->setPackage($package);
|
||||||
|
|
||||||
// initialize installation manager
|
// initialize installation manager
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
namespace Composer\Package\Loader;
|
namespace Composer\Package\Loader;
|
||||||
|
|
||||||
use Composer\Package\BasePackage;
|
use Composer\Package\BasePackage;
|
||||||
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Package\AliasPackage;
|
use Composer\Package\AliasPackage;
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
use Composer\Factory;
|
use Composer\Factory;
|
||||||
|
@ -54,7 +55,13 @@ class RootPackageLoader extends ArrayLoader
|
||||||
$this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor(), $this->versionParser);
|
$this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor(), $this->versionParser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(array $config, $class = 'Composer\Package\RootPackage')
|
/**
|
||||||
|
* @param array $config package data
|
||||||
|
* @param string $class FQCN to be instantiated
|
||||||
|
* @param string $cwd cwd of the root package to be used to guess the version if it is not provided
|
||||||
|
* @return PackageInterface
|
||||||
|
*/
|
||||||
|
public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
|
||||||
{
|
{
|
||||||
if (!isset($config['name'])) {
|
if (!isset($config['name'])) {
|
||||||
$config['name'] = '__root__';
|
$config['name'] = '__root__';
|
||||||
|
@ -65,7 +72,7 @@ class RootPackageLoader extends ArrayLoader
|
||||||
if (getenv('COMPOSER_ROOT_VERSION')) {
|
if (getenv('COMPOSER_ROOT_VERSION')) {
|
||||||
$version = getenv('COMPOSER_ROOT_VERSION');
|
$version = getenv('COMPOSER_ROOT_VERSION');
|
||||||
} else {
|
} else {
|
||||||
$version = $this->versionGuesser->guessVersion($config, getcwd());
|
$version = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$version) {
|
if (!$version) {
|
||||||
|
|
Loading…
Reference in New Issue