1
0
Fork 0

Merge pull request #2629 from moranjk/master

Implemented Pre/Post Archive Script Events
pull/2642/merge
Nils Adermann 2014-01-29 01:12:19 -08:00
commit 0238aaf5ac
3 changed files with 29 additions and 1 deletions

View File

@ -40,6 +40,8 @@ Composer fires the following named events during its execution process:
installed, during the `create-project` command. installed, during the `create-project` command.
- **post-create-project-cmd**: occurs after the `create-project` command is - **post-create-project-cmd**: occurs after the `create-project` command is
executed. executed.
- **pre-archive-cmd**: occurs before the `archive` command is executed.
- **post-archive-cmd**: occurs after the `archive` command is executed.
**NOTE: Composer makes no assumptions about the state of your dependencies **NOTE: Composer makes no assumptions about the state of your dependencies
prior to `install` or `update`. Therefore, you should not specify scripts that prior to `install` or `update`. Therefore, you should not specify scripts that

View File

@ -17,6 +17,7 @@ use Composer\IO\IOInterface;
use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Pool;
use Composer\Package\LinkConstraint\VersionConstraint; use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Repository\CompositeRepository; use Composer\Repository\CompositeRepository;
use Composer\Script\ScriptEvents;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -55,13 +56,20 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
return $this->archive( $this->getComposer()->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
$returnCode = $this->archive(
$this->getIO(), $this->getIO(),
$input->getArgument('package'), $input->getArgument('package'),
$input->getArgument('version'), $input->getArgument('version'),
$input->getOption('format'), $input->getOption('format'),
$input->getOption('dir') $input->getOption('dir')
); );
if (0 === $returnCode) {
$this->getComposer()->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
}
return $returnCode;
} }
protected function archive(IOInterface $io, $packageName = null, $version = null, $format = 'tar', $dest = '.') protected function archive(IOInterface $io, $packageName = null, $version = null, $format = 'tar', $dest = '.')

View File

@ -165,4 +165,22 @@ class ScriptEvents
*/ */
const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd'; const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
/**
* The PRE_ARCHIVE_CMD event occurs before the update command is executed.
*
* The event listener method receives a Composer\Script\CommandEvent instance.
*
* @var string
*/
const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
/**
* The POST_ARCHIVE_CMD event occurs after the status command is executed.
*
* The event listener method receives a Composer\Script\CommandEvent instance.
*
* @var string
*/
const POST_ARCHIVE_CMD = 'post-archive-cmd';
} }