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

Add pre-status-cmd and post-status-cmd script hooks
main
Jordi Boggiano 11 years ago
commit 5b042943e3

@ -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.

@ -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."

@ -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));

@ -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;
}
}

@ -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.
*

Loading…
Cancel
Save