Implemented Pre/Post Archive Script Events

The script events `pre-archive-cmd` and `post-archive-cmd` can be used
to perform any tasks necessary when archiving the composer project.

This functionality can be used to run unit test or and other build
process before archiving, and can be used to distribute the archive
when completed
main
James Moran 11 years ago
parent 69e77fbbb5
commit ee7961a0f3

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

@ -165,4 +165,22 @@ class ScriptEvents
*/
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';
}

Loading…
Cancel
Save