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