Suppress require-dev hint when requiring things globally, fixes #12253
parent
7b1655bc62
commit
c1256a2920
|
@ -231,7 +231,7 @@ EOT
|
||||||
|
|
||||||
$requirements = $this->formatRequirements($requirements);
|
$requirements = $this->formatRequirements($requirements);
|
||||||
|
|
||||||
if (!$input->getOption('dev') && $io->isInteractive()) {
|
if (!$input->getOption('dev') && $io->isInteractive() && !$composer->isGlobal()) {
|
||||||
$devPackages = [];
|
$devPackages = [];
|
||||||
$devTags = ['dev', 'testing', 'static analysis'];
|
$devTags = ['dev', 'testing', 'static analysis'];
|
||||||
$currentRequiresByKey = $this->getPackagesByRequireKey();
|
$currentRequiresByKey = $this->getPackagesByRequireKey();
|
||||||
|
|
|
@ -324,7 +324,9 @@ class Factory
|
||||||
|
|
||||||
// Load config and override with local config/auth config
|
// Load config and override with local config/auth config
|
||||||
$config = static::createConfig($io, $cwd);
|
$config = static::createConfig($io, $cwd);
|
||||||
|
$isGlobal = $localConfigSource !== Config::SOURCE_UNKNOWN && realpath($config->get('home')) === realpath(dirname($localConfigSource));
|
||||||
$config->merge($localConfig, $localConfigSource);
|
$config->merge($localConfig, $localConfigSource);
|
||||||
|
|
||||||
if (isset($composerFile)) {
|
if (isset($composerFile)) {
|
||||||
$io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
|
$io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
|
||||||
$config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
|
$config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
|
||||||
|
@ -346,6 +348,9 @@ class Factory
|
||||||
// initialize composer
|
// initialize composer
|
||||||
$composer = $fullLoad ? new Composer() : new PartialComposer();
|
$composer = $fullLoad ? new Composer() : new PartialComposer();
|
||||||
$composer->setConfig($config);
|
$composer->setConfig($config);
|
||||||
|
if ($isGlobal) {
|
||||||
|
$composer->setGlobal();
|
||||||
|
}
|
||||||
|
|
||||||
if ($fullLoad) {
|
if ($fullLoad) {
|
||||||
// load auth configs into the IO instance
|
// load auth configs into the IO instance
|
||||||
|
@ -429,14 +434,14 @@ class Factory
|
||||||
|
|
||||||
if ($composer instanceof Composer) {
|
if ($composer instanceof Composer) {
|
||||||
$globalComposer = null;
|
$globalComposer = null;
|
||||||
if (realpath($config->get('home')) !== $cwd) {
|
if (!$composer->isGlobal()) {
|
||||||
$globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins, $disableScripts);
|
$globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins, $disableScripts);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
|
$pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
|
||||||
$composer->setPluginManager($pm);
|
$composer->setPluginManager($pm);
|
||||||
|
|
||||||
if (realpath($config->get('home')) === $cwd) {
|
if ($composer->isGlobal()) {
|
||||||
$pm->setRunningInGlobalDir(true);
|
$pm->setRunningInGlobalDir(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,11 @@ use Composer\EventDispatcher\EventDispatcher;
|
||||||
*/
|
*/
|
||||||
class PartialComposer
|
class PartialComposer
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $global = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var RootPackageInterface
|
* @var RootPackageInterface
|
||||||
*/
|
*/
|
||||||
|
@ -112,4 +117,14 @@ class PartialComposer
|
||||||
{
|
{
|
||||||
return $this->eventDispatcher;
|
return $this->eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isGlobal(): bool
|
||||||
|
{
|
||||||
|
return $this->global;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGlobal(): void
|
||||||
|
{
|
||||||
|
$this->global = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue