Add --dev flag to InstallCommand to do source installs, fixes #26

main
Jordi Boggiano 13 years ago
parent 36a724fa51
commit 6b6d6b6d82

@ -21,7 +21,7 @@ $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
$rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
// initialize download manager
$dm = new Downloader\DownloadManager($preferSource = false);
$dm = new Downloader\DownloadManager();
$dm->setDownloader('git', new Downloader\GitDownloader());
$dm->setDownloader('pear', new Downloader\PearDownloader());
$dm->setDownloader('zip', new Downloader\ZipDownloader());

@ -20,6 +20,7 @@ use Composer\DependencyResolver\Operation;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Repository\PlatformRepository;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
@ -34,6 +35,9 @@ class InstallCommand extends Command
$this
->setName('install')
->setDescription('Parses the composer.json file and downloads the needed dependencies.')
->setDefinition(array(
new InputOption('dev', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
))
->setHelp(<<<EOT
The <info>install</info> command reads the composer.json file from the
current directory, processes it, and downloads and installs all the
@ -50,6 +54,10 @@ EOT
{
$composer = $this->getComposer();
if ($input->getOption('dev')) {
$composer->getDownloadManager()->setPreferSource(true);
}
// create local repo, this contains all packages that are installed in the local project
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
// create installed repo, this contains all local packages + platform packages (php & extensions)

@ -40,7 +40,7 @@ class DownloadManager
*
* @param Boolean $preferSource prefer downloading from source
*/
public function preferSource($preferSource = true)
public function setPreferSource($preferSource)
{
$this->preferSource = $preferSource;
}

@ -326,7 +326,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
->with($package)
->will($this->returnValue($downloader));
$manager->preferSource();
$manager->setPreferSource(true);
$manager->download($package, 'target_dir');
}
@ -362,7 +362,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
->with($package)
->will($this->returnValue($downloader));
$manager->preferSource();
$manager->setPreferSource(true);
$manager->download($package, 'target_dir');
}
@ -398,7 +398,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
->with($package)
->will($this->returnValue($downloader));
$manager->preferSource();
$manager->setPreferSource(true);
$manager->download($package, 'target_dir');
}
@ -415,7 +415,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue(null));
$manager = new DownloadManager();
$manager->preferSource();
$manager->setPreferSource(true);
$this->setExpectedException('InvalidArgumentException');
$manager->download($package, 'target_dir');

Loading…
Cancel
Save