1
0
Fork 0

Merge pull request #2138 from sascha-egerer/feature/add_status_event_scripts

Add pre-status-cmd and post-status-cmd script hooks
pull/2105/merge
Jordi Boggiano 2013-08-01 03:26:21 -07:00
commit 5b042943e3
5 changed files with 37 additions and 0 deletions

View File

@ -24,6 +24,8 @@ Composer fires the following named events during its execution process:
- **post-install-cmd**: occurs after the `install` command is executed.
- **pre-update-cmd**: occurs before the `update` command is executed.
- **post-update-cmd**: occurs after the `update` command is executed.
- **pre-status-cmd**: occurs before the `status` command is executed.
- **post-status-cmd**: occurs after the `status` command is executed.
- **pre-package-install**: occurs before a package is installed.
- **post-package-install**: occurs after a package is installed.
- **pre-package-update**: occurs before a package is updated.

View File

@ -259,6 +259,14 @@
"type": ["array", "string"],
"description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
},
"pre-status-cmd": {
"type": ["array", "string"],
"description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
},
"post-status-cmd": {
"type": ["array", "string"],
"description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
},
"pre-package-install": {
"type": ["array", "string"],
"description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."

View File

@ -50,6 +50,8 @@ EOT
ScriptEvents::POST_INSTALL_CMD,
ScriptEvents::PRE_UPDATE_CMD,
ScriptEvents::POST_UPDATE_CMD,
ScriptEvents::PRE_STATUS_CMD,
ScriptEvents::POST_STATUS_CMD,
))) {
if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));

View File

@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\Downloader\ChangeReportInterface;
use Composer\Downloader\VcsDownloader;
use Composer\Script\ScriptEvents;
/**
* @author Tiago Ribeiro <tiago.ribeiro@seegno.com>
@ -50,6 +51,9 @@ EOT
$dm = $composer->getDownloadManager();
$im = $composer->getInstallationManager();
// Dispatch pre-status-command
$composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::PRE_STATUS_CMD, true);
$errors = array();
// list packages
@ -88,6 +92,9 @@ EOT
$output->writeln('Use --verbose (-v) to see modified files');
}
// Dispatch post-status-command
$composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::POST_STATUS_CMD, true);
return $errors ? 1 : 0;
}
}

View File

@ -56,6 +56,24 @@ class ScriptEvents
*/
const POST_UPDATE_CMD = 'post-update-cmd';
/**
* The PRE_STATUS_CMD event occurs before the status command is executed.
*
* The event listener method receives a Composer\Script\CommandEvent instance.
*
* @var string
*/
const PRE_STATUS_CMD = 'pre-status-cmd';
/**
* The POST_STATUS_CMD event occurs after the status command is executed.
*
* The event listener method receives a Composer\Script\CommandEvent instance.
*
* @var string
*/
const POST_STATUS_CMD = 'post-status-cmd';
/**
* The PRE_PACKAGE_INSTALL event occurs before a package is installed.
*