Skip to content

Commit

Permalink
use autoload file from root-library vendor dir if it exists, fixes GH-7
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Heleniak committed Apr 1, 2012
1 parent d164989 commit 98fc114
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
7 changes: 1 addition & 6 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#!/usr/bin/env php
<?php

if (!@include __DIR__.'/../vendor/.composer/autoload.php') {
die('You must set up the project dependencies, run the following commands:
wget http://getcomposer.org/composer.phar
php composer.phar install
');
}
require __DIR__.'/../src/bootstrap.php';

use Composer\Satis\Compiler;

Expand Down
7 changes: 1 addition & 6 deletions bin/satis
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#!/usr/bin/env php
<?php

if (!@include __DIR__.'/../vendor/.composer/autoload.php') {
die('You must set up the project dependencies, run the following commands:
wget http://getcomposer.org/composer.phar
php composer.phar install
');
}
require __DIR__.'/../src/bootstrap.php';

use Composer\Satis\Console\Application;

Expand Down
25 changes: 25 additions & 0 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/*
* This file is part of Satis.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

function includeIfExists($file) {
if (file_exists($file)) {
return include $file;
}
}

if ((!$loader = includeIfExists(__DIR__.'/../../../.composer/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../vendor/.composer/autoload.php'))) {
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL);
}

return $loader;
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
* file that was distributed with this source code.
*/

$loader = require __DIR__.'/../vendor/.composer/autoload.php';
$loader = require __DIR__.'/../src/bootstrap.php';
$loader->add('Composer\Test', __DIR__);

0 comments on commit 98fc114

Please sign in to comment.