1
0
Fork 0

Merge remote-tracking branch 'pjedrzejewski/feature/skipping-scripts-execution'

Conflicts:
	src/Composer/Installer.php
pull/727/head
Jordi Boggiano 2012-05-23 11:11:19 +02:00
commit 1f2f161508
3 changed files with 25 additions and 5 deletions

View File

@ -33,6 +33,7 @@ class InstallCommand extends Command
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'), new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'), new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'), new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
new InputOption('skip-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
)) ))
->setHelp(<<<EOT ->setHelp(<<<EOT
The <info>install</info> command reads the composer.json file from the The <info>install</info> command reads the composer.json file from the
@ -57,6 +58,7 @@ EOT
->setVerbose($input->getOption('verbose')) ->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source')) ->setPreferSource($input->getOption('prefer-source'))
->setDevMode($input->getOption('dev')) ->setDevMode($input->getOption('dev'))
->setRunScripts(!$input->getOption('skip-scripts'))
; ;
return $install->run() ? 0 : 1; return $install->run() ? 0 : 1;

View File

@ -31,6 +31,7 @@ class UpdateCommand extends Command
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'), new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'), new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'), new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
new InputOption('skip-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
)) ))
->setHelp(<<<EOT ->setHelp(<<<EOT
The <info>update</info> command reads the composer.json file from the The <info>update</info> command reads the composer.json file from the
@ -55,6 +56,7 @@ EOT
->setVerbose($input->getOption('verbose')) ->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source')) ->setPreferSource($input->getOption('prefer-source'))
->setDevMode($input->getOption('dev')) ->setDevMode($input->getOption('dev'))
->setRunScripts(!$input->getOption('skip-scripts'))
->setUpdate(true) ->setUpdate(true)
; ;

View File

@ -87,6 +87,7 @@ class Installer
protected $dryRun = false; protected $dryRun = false;
protected $verbose = false; protected $verbose = false;
protected $update = false; protected $update = false;
protected $runScripts = true;
/** /**
* @var array * @var array
@ -150,7 +151,7 @@ class Installer
$aliases = $this->aliasPackages(); $aliases = $this->aliasPackages();
if (!$this->dryRun) { if (!$this->dryRun && $this->runScripts) {
// dispatch pre event // dispatch pre event
$eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD; $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
$this->eventDispatcher->dispatchCommandEvent($eventName); $this->eventDispatcher->dispatchCommandEvent($eventName);
@ -193,9 +194,11 @@ class Installer
$localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories()); $localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories());
$this->autoloadGenerator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath() . '/composer', true); $this->autoloadGenerator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath() . '/composer', true);
// dispatch post event if ($this->runScripts) {
$eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; // dispatch post event
$this->eventDispatcher->dispatchCommandEvent($eventName); $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
$this->eventDispatcher->dispatchCommandEvent($eventName);
}
} }
return true; return true;
@ -518,7 +521,7 @@ class Installer
/** /**
* enables dev packages * enables dev packages
* *
* @param boolean $update * @param boolean $devMode
* @return Installer * @return Installer
*/ */
public function setDevMode($devMode = true) public function setDevMode($devMode = true)
@ -528,6 +531,19 @@ class Installer
return $this; return $this;
} }
/**
* set whether to run scripts or not
*
* @param boolean $runScripts
* @return Installer
*/
public function setRunScripts($runScripts = true)
{
$this->runScripts = (boolean) $runScripts;
return $this;
}
/** /**
* run in verbose mode * run in verbose mode
* *