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