From cc8b33117a89bb1feced40f434549ff2f2029790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20J=C4=99drzejewski?= Date: Mon, 16 Apr 2012 19:45:06 +0200 Subject: [PATCH 1/3] add --skip-scripts option to install/update commands. --- src/Composer/Command/InstallCommand.php | 2 ++ src/Composer/Command/UpdateCommand.php | 2 ++ src/Composer/Installer.php | 26 ++++++++++++++++++++----- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index bb6c636b6..bbe4f0631 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -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('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('skip-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defines in composer.json file.'), )) ->setHelp(<<install command reads the composer.json file from the @@ -57,6 +58,7 @@ EOT ->setVerbose($input->getOption('verbose')) ->setPreferSource($input->getOption('prefer-source')) ->setDevMode($input->getOption('dev')) + ->setSkipScripts($input->getOption('skip-scripts')) ; return $install->run() ? 0 : 1; diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index ffc848d87..7f458bf11 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -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('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('skip-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defines in composer.json file.'), )) ->setHelp(<<update command reads the composer.json file from the @@ -55,6 +56,7 @@ EOT ->setVerbose($input->getOption('verbose')) ->setPreferSource($input->getOption('prefer-source')) ->setDevMode($input->getOption('dev')) + ->setSkipScripts($input->getOption('skip-scripts')) ->setUpdate(true) ; diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 0eed0050a..5d4cc8419 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -88,6 +88,7 @@ class Installer protected $dryRun = false; protected $verbose = false; protected $update = false; + protected $skipScripts = false; /** * @var array @@ -151,7 +152,7 @@ class Installer $aliases = $this->aliasPackages(); - if (!$this->dryRun) { + if (!$this->dryRun && !$this->skipScripts) { // dispatch pre event $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD; $this->eventDispatcher->dispatchCommandEvent($eventName); @@ -194,9 +195,11 @@ class Installer $localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories()); $this->autoloadGenerator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath() . '/composer', true); - // dispatch post event - $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; - $this->eventDispatcher->dispatchCommandEvent($eventName); + if (!$this->skipScripts) { + // dispatch post event + $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; + $this->eventDispatcher->dispatchCommandEvent($eventName); + } } return true; @@ -496,7 +499,7 @@ class Installer /** * enables dev packages * - * @param boolean $update + * @param boolean $devMode * @return Installer */ public function setDevMode($devMode = true) @@ -506,6 +509,19 @@ class Installer return $this; } + /** + * skips scripts execution + * + * @param boolean $skipScripts + * @return Installer + */ + public function setSkipScripts($skipScripts = true) + { + $this->skipScripts = (boolean) $skipScripts; + + return $this; + } + /** * run in verbose mode * From 123dec52fb652f4013125d545e9e0fc12295599f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20J=C4=99drzejewski?= Date: Mon, 16 Apr 2012 19:57:44 +0200 Subject: [PATCH 2/3] typos in command option description. --- src/Composer/Command/InstallCommand.php | 2 +- src/Composer/Command/UpdateCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index bbe4f0631..773167399 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -33,7 +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('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('skip-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defines in composer.json file.'), + new InputOption('skip-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), )) ->setHelp(<<install command reads the composer.json file from the diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 7f458bf11..e9ed94ec1 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -31,7 +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('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('skip-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defines in composer.json file.'), + new InputOption('skip-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), )) ->setHelp(<<update command reads the composer.json file from the From 129884ef72f7b049467fdff32f8463f5e4705631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20J=C4=99drzejewski?= Date: Sun, 13 May 2012 13:25:02 +0200 Subject: [PATCH 3/3] rename skipScripts to runScripts. --- src/Composer/Command/InstallCommand.php | 2 +- src/Composer/Command/UpdateCommand.php | 2 +- src/Composer/Installer.php | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 773167399..3f919d198 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -58,7 +58,7 @@ EOT ->setVerbose($input->getOption('verbose')) ->setPreferSource($input->getOption('prefer-source')) ->setDevMode($input->getOption('dev')) - ->setSkipScripts($input->getOption('skip-scripts')) + ->setRunScripts(!$input->getOption('skip-scripts')) ; return $install->run() ? 0 : 1; diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index e9ed94ec1..2d42713fc 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -56,7 +56,7 @@ EOT ->setVerbose($input->getOption('verbose')) ->setPreferSource($input->getOption('prefer-source')) ->setDevMode($input->getOption('dev')) - ->setSkipScripts($input->getOption('skip-scripts')) + ->setRunScripts(!$input->getOption('skip-scripts')) ->setUpdate(true) ; diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 5d4cc8419..2d5c6c832 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -88,7 +88,7 @@ class Installer protected $dryRun = false; protected $verbose = false; protected $update = false; - protected $skipScripts = false; + protected $runScripts = true; /** * @var array @@ -152,7 +152,7 @@ class Installer $aliases = $this->aliasPackages(); - if (!$this->dryRun && !$this->skipScripts) { + if (!$this->dryRun && $this->runScripts) { // dispatch pre event $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD; $this->eventDispatcher->dispatchCommandEvent($eventName); @@ -195,7 +195,7 @@ class Installer $localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories()); $this->autoloadGenerator->dump($localRepos, $this->package, $this->installationManager, $this->installationManager->getVendorPath() . '/composer', true); - if (!$this->skipScripts) { + if ($this->runScripts) { // dispatch post event $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; $this->eventDispatcher->dispatchCommandEvent($eventName); @@ -510,14 +510,14 @@ class Installer } /** - * skips scripts execution + * set whether to run scripts or not * - * @param boolean $skipScripts + * @param boolean $runScripts * @return Installer */ - public function setSkipScripts($skipScripts = true) + public function setRunScripts($runScripts = true) { - $this->skipScripts = (boolean) $skipScripts; + $this->runScripts = (boolean) $runScripts; return $this; }