From 36ccd38aa75d7ec9afb820745b49f875022df7f4 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Mon, 27 Feb 2012 20:52:41 +0100 Subject: [PATCH] Directly install dependencies --- src/Composer/Command/CreateProjectCommand.php | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 6cbf0f3fc..5677a0553 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -15,6 +15,7 @@ namespace Composer\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\OutputInterface; use Composer\IO\IOInterface; use Composer\Factory; @@ -66,6 +67,7 @@ EOT return $this->installProject( $io, + $this->getInstallCommand($input, $output), $input->getArgument('package'), $input->getArgument('directory'), $input->getArgument('version'), @@ -74,7 +76,16 @@ EOT ); } - public function installProject(IOInterface $io, $packageName, $directory = null, $version = null, $preferSource = false, $repositoryUrl = null) + protected function getInstallCommand($input, $output) + { + $app = $this->getApplication(); + return function() use ($app, $input, $output) { + $newInput = new ArrayInput(array('command' => 'install')); + $app->doRUn($newInput, $output); + }; + } + + public function installProject(IOInterface $io, $installCommand, $packageName, $directory = null, $version = null, $preferSource = false, $repositoryUrl = null) { $dm = $this->createDownloadManager($io); if ($preferSource) { @@ -101,13 +112,13 @@ EOT $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts); } + $io->write('Installing ' . $package->getName() . ' as new project.', true); $projectInstaller = new ProjectInstaller($directory, $dm); $projectInstaller->install($package); - $io->write('Created new project directory for ' . $package->getName(), true); - $io->write('Next steps:', true); - $io->write('1. cd ' . $directory, true); - $io->write('2. composer install', true); + $io->write('Created project into directory ' . $directory . '', true); + chdir($directory); + $installCommand(); } protected function createDownloadManager(IOInterface $io)