Skip to content

Commit

Permalink
Improve bin
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor authored Apr 25, 2024
1 parent 63f56a7 commit e19fb6a
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions bin/strauss
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
#!/usr/bin/env php
<?php
call_user_func(function ($version) {
if( ! Phar::running() ) {
if (is_file($autoload = getcwd() . '/vendor/autoload.php')) {
require $autoload;
} elseif (is_file($autoload = getcwd() . '/../../autoload.php')) {
require $autoload;
}
$autoloaders = Phar::running() === ''
? []
: [__DIR__ . '/../vendor/autoload.php'];
$autoloaders[] = getcwd() . '/vendor/autoload.php';
$autoloaders[] = getcwd() . '/../../autoload.php';
$autoloaders[] = __DIR__ . '/../vendor/autoload.php';
$autoloaders[] = __DIR__ . '/../../../autoload.php';

if ( is_file( $autoload = __DIR__ . '/../vendor/autoload.php' ) ) {
require( $autoload );
} elseif ( is_file( $autoload = __DIR__ . '/../../../autoload.php' ) ) {
require( $autoload );
} else {
fwrite( STDERR,
'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
);
exit( 1 );
foreach ($autoloaders as $autoloader) {
if (!is_file($autoloader)) {
continue;
}
} else {
include __DIR__ . '/../vendor/autoload.php';
require $autoloader;
break;
}

if (!class_exists(Composer\Autoload\ClassLoader::class)) {
fwrite(STDERR,
'You must set up the project dependencies, run the following commands:' . PHP_EOL
. 'curl -s https://getcomposer.org/installer | php' . PHP_EOL
. 'php composer.phar install' . PHP_EOL
);
exit(1);
}

$app = new BrianHenryIE\Strauss\Console\Application($version);
Expand Down

0 comments on commit e19fb6a

Please sign in to comment.