Fix --no-scripts disabling events for plugins
parent
288e19153d
commit
eac069bf36
|
@ -183,6 +183,7 @@ EOT
|
|||
}
|
||||
|
||||
$composer = Factory::create($io, null, $disablePlugins);
|
||||
$composer->getEventDispatcher()->setRunScripts(!$noScripts);
|
||||
|
||||
// add the repository to the composer.json and use it for the install run later
|
||||
if ($repositories !== null && $addRepository) {
|
||||
|
@ -208,10 +209,8 @@ EOT
|
|||
$process = new ProcessExecutor($io);
|
||||
$fs = new Filesystem($process);
|
||||
|
||||
if ($noScripts === false) {
|
||||
// dispatch event
|
||||
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
|
||||
}
|
||||
// dispatch event
|
||||
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
|
||||
|
||||
// use the new config including the newly installed project
|
||||
$config = $composer->getConfig();
|
||||
|
@ -225,7 +224,6 @@ EOT
|
|||
$installer->setPreferSource($preferSource)
|
||||
->setPreferDist($preferDist)
|
||||
->setDevMode($installDevPackages)
|
||||
->setRunScripts(!$noScripts)
|
||||
->setIgnorePlatformRequirements($ignorePlatformReqs)
|
||||
->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
|
||||
->setOptimizeAutoloader($config->get('optimize-autoloader'))
|
||||
|
@ -290,10 +288,8 @@ EOT
|
|||
}
|
||||
}
|
||||
|
||||
if ($noScripts === false) {
|
||||
// dispatch event
|
||||
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
|
||||
}
|
||||
// dispatch event
|
||||
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
|
||||
|
||||
chdir($oldCwd);
|
||||
$vendorComposerDir = $config->get('vendor-dir').'/composer';
|
||||
|
|
|
@ -52,6 +52,7 @@ EOT
|
|||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$composer = $this->getComposer();
|
||||
$composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
|
||||
|
||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
|
||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||
|
@ -82,7 +83,6 @@ EOT
|
|||
}
|
||||
$generator->setClassMapAuthoritative($authoritative);
|
||||
$generator->setApcu($apcu, $apcuPrefix);
|
||||
$generator->setRunScripts(!$input->getOption('no-scripts'));
|
||||
$generator->setIgnorePlatformRequirements($ignorePlatformReqs);
|
||||
$numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
|
||||
|
||||
|
|
|
@ -94,6 +94,7 @@ EOT
|
|||
}
|
||||
|
||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||
$composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
|
||||
|
||||
if ((!$composer->getLocker() || !$composer->getLocker()->isLocked()) && !HttpDownloader::isCurlEnabled()) {
|
||||
$io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
|
||||
|
@ -123,7 +124,6 @@ EOT
|
|||
->setPreferDist($preferDist)
|
||||
->setDevMode(!$input->getOption('no-dev'))
|
||||
->setDumpAutoloader(!$input->getOption('no-autoloader'))
|
||||
->setRunScripts(!$input->getOption('no-scripts'))
|
||||
->setOptimizeAutoloader($optimize)
|
||||
->setClassMapAuthoritative($authoritative)
|
||||
->setApcuAutoloader($apcu, $apcuPrefix)
|
||||
|
|
|
@ -202,6 +202,7 @@ EOT
|
|||
// Update packages
|
||||
$this->resetComposer();
|
||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||
$composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
|
||||
|
||||
if ($dryRun) {
|
||||
$rootPackage = $composer->getPackage();
|
||||
|
@ -255,7 +256,6 @@ EOT
|
|||
->setInstall(!$input->getOption('no-install'))
|
||||
->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
|
||||
->setIgnorePlatformRequirements($ignorePlatformReqs)
|
||||
->setRunScripts(!$input->getOption('no-scripts'))
|
||||
->setDryRun($dryRun)
|
||||
;
|
||||
|
||||
|
|
|
@ -311,6 +311,7 @@ EOT
|
|||
// Update packages
|
||||
$this->resetComposer();
|
||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||
$composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
|
||||
|
||||
if ($input->getOption('dry-run')) {
|
||||
$rootPackage = $composer->getPackage();
|
||||
|
@ -362,7 +363,6 @@ EOT
|
|||
->setPreferSource($preferSource)
|
||||
->setPreferDist($preferDist)
|
||||
->setDevMode($updateDevMode)
|
||||
->setRunScripts(!$input->getOption('no-scripts'))
|
||||
->setOptimizeAutoloader($optimize)
|
||||
->setClassMapAuthoritative($authoritative)
|
||||
->setApcuAutoloader($apcu, $apcuPrefix)
|
||||
|
|
|
@ -116,6 +116,7 @@ EOT
|
|||
}
|
||||
|
||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||
$composer->getEventDispatcher()->setRunScripts(!$input->getOption('no-scripts'));
|
||||
|
||||
if (!HttpDownloader::isCurlEnabled()) {
|
||||
$io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
|
||||
|
@ -220,7 +221,6 @@ EOT
|
|||
->setPreferDist($preferDist)
|
||||
->setDevMode(!$input->getOption('no-dev'))
|
||||
->setDumpAutoloader(!$input->getOption('no-autoloader'))
|
||||
->setRunScripts(!$input->getOption('no-scripts'))
|
||||
->setOptimizeAutoloader($optimize)
|
||||
->setClassMapAuthoritative($authoritative)
|
||||
->setApcuAutoloader($apcu, $apcuPrefix)
|
||||
|
|
|
@ -53,6 +53,8 @@ class EventDispatcher
|
|||
protected $process;
|
||||
/** @var array<string, array<int, array<callable|string>>> */
|
||||
protected $listeners = array();
|
||||
/** @var bool */
|
||||
protected $runScripts = true;
|
||||
/** @var list<string> */
|
||||
private $eventStack;
|
||||
|
||||
|
@ -71,6 +73,18 @@ class EventDispatcher
|
|||
$this->eventStack = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to run scripts or not
|
||||
*
|
||||
* @param bool $runScripts
|
||||
*/
|
||||
public function setRunScripts($runScripts = true)
|
||||
{
|
||||
$this->runScripts = (bool) $runScripts;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch an event
|
||||
*
|
||||
|
@ -421,7 +435,7 @@ class EventDispatcher
|
|||
*/
|
||||
protected function getListeners(Event $event)
|
||||
{
|
||||
$scriptListeners = $this->getScriptListeners($event);
|
||||
$scriptListeners = $this->runScripts ? $this->getScriptListeners($event) : array();
|
||||
|
||||
if (!isset($this->listeners[$event->getName()][0])) {
|
||||
$this->listeners[$event->getName()][0] = array();
|
||||
|
|
Loading…
Reference in New Issue