1
0
Fork 0

Minor adjustments to merged PR

pull/122/merge
Jordi Boggiano 2011-11-20 22:02:22 +01:00
parent 5b87a02767
commit f5b7e968b2
5 changed files with 20 additions and 19 deletions

View File

@ -35,12 +35,11 @@ if (isset($packageConfig['config']) && is_array($packageConfig['config'])) {
$packageConfig['config'] = $composerConfig; $packageConfig['config'] = $composerConfig;
} }
// easy local access $vendorDir = $packageConfig['config']['vendor-dir'];
$vendorPath = $packageConfig['config']['vendor-dir'];
// initialize repository manager // initialize repository manager
$rm = new Repository\RepositoryManager(); $rm = new Repository\RepositoryManager();
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorPath.'/.composer/installed.json'))); $rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository'); $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository'); $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository'); $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
@ -55,9 +54,9 @@ $dm->setDownloader('pear', new Downloader\PearDownloader());
$dm->setDownloader('zip', new Downloader\ZipDownloader()); $dm->setDownloader('zip', new Downloader\ZipDownloader());
// initialize installation manager // initialize installation manager
$im = new Installer\InstallationManager($vendorPath); $im = new Installer\InstallationManager($vendorDir);
$im->addInstaller(new Installer\LibraryInstaller($vendorPath, $dm, $rm->getLocalRepository(), null)); $im->addInstaller(new Installer\LibraryInstaller($vendorDir, $dm, $rm->getLocalRepository(), null));
$im->addInstaller(new Installer\InstallerInstaller($vendorPath, $dm, $rm->getLocalRepository(), $im)); $im->addInstaller(new Installer\InstallerInstaller($vendorDir, $dm, $rm->getLocalRepository(), $im));
// load package // load package
$loader = new Package\Loader\ArrayLoader($rm); $loader = new Package\Loader\ArrayLoader($rm);

View File

@ -54,6 +54,8 @@ EOF;
// autoload_namespace.php generated by Composer // autoload_namespace.php generated by Composer
$baseDir = dirname(__DIR__);
return array( return array(
EOF; EOF;
@ -77,7 +79,7 @@ EOF;
foreach ($autoloads['psr-0'] as $def) { foreach ($autoloads['psr-0'] as $def) {
if (!$this->isAbsolutePath($def['path'])) { if (!$this->isAbsolutePath($def['path'])) {
$def['path'] = substr($def['path'], strlen($vendorPath)); $def['path'] = substr($def['path'], strlen($vendorPath));
$baseDir = "dirname(__DIR__)."; $baseDir = '$baseDir . ';
} else { } else {
$baseDir = ''; $baseDir = '';
} }

View File

@ -33,20 +33,20 @@ class InstallationManager
/** /**
* Creates an instance of InstallationManager * Creates an instance of InstallationManager
* *
* @param string $vendorPath Relative path to the vendor directory * @param string $vendorDir Relative path to the vendor directory
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function __construct($vendorPath = 'vendor') public function __construct($vendorDir = 'vendor')
{ {
if (substr($vendorPath, 0, 1) === '/' || substr($vendorPath, 1, 1) === ':') { if (substr($vendorDir, 0, 1) === '/' || substr($vendorDir, 1, 1) === ':') {
$basePath = getcwd(); $basePath = getcwd();
if (0 !== strpos($vendorPath, $basePath)) { if (0 !== strpos($vendorDir, $basePath)) {
throw new \InvalidArgumentException("Vendor path ($vendorPath) must be within the current working directory ($basePath)."); throw new \InvalidArgumentException("Vendor dir ($vendorDir) must be within the current working directory ($basePath).");
} }
// convert to relative path // convert to relative path
$this->vendorPath = substr($vendorPath, strlen($basePath)+1); $this->vendorPath = substr($vendorDir, strlen($basePath)+1);
} else { } else {
$this->vendorPath = $vendorPath; $this->vendorPath = $vendorDir;
} }
} }

View File

@ -209,7 +209,7 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
public function testGetVendorPathAbsolute() public function testGetVendorPathAbsolute()
{ {
$manager = new InstallationManager('vendor'); $manager = new InstallationManager('vendor');
$this->assertEquals(realpath('').DIRECTORY_SEPARATOR.'vendor', $manager->getVendorPath(true)); $this->assertEquals(getcwd().DIRECTORY_SEPARATOR.'vendor', $manager->getVendorPath(true));
} }
public function testGetVendorPathRelative() public function testGetVendorPathRelative()