48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
#!/usr/bin/env php
|
|
<?php
|
|
$autoloaders = [];
|
|
|
|
$vendorDir = 'vendor';
|
|
|
|
if ($composerPath = realpath(getcwd() . '/composer.json')) {
|
|
$composerJson = json_decode(file_get_contents($composerPath), true);
|
|
$vendorDir = isset($composerJson['vendor-dir']) ? $composerJson['vendor-dir'] : $vendorDir;
|
|
}
|
|
|
|
if ($relative = realpath(getcwd() . "/{$vendorDir}/autoload.php")) {
|
|
$autoloaders[] = include $relative;
|
|
}
|
|
|
|
if (!$absolute = realpath(__DIR__ . '/../../../autoload.php')) {
|
|
$absolute = realpath(__DIR__ . '/../vendor/autoload.php');
|
|
}
|
|
|
|
if ($absolute && $relative !== $absolute) {
|
|
$autoloaders[] = include $absolute;
|
|
}
|
|
|
|
if (!$autoloaders) {
|
|
echo "\033[1;31mYou need to set up the project dependencies using the following commands: \033[0m" . PHP_EOL;
|
|
echo 'curl -s http://getcomposer.org/installer | php' . PHP_EOL;
|
|
echo 'php composer.phar install' . PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
use Kahlan\Box\Box;
|
|
use Kahlan\Suite;
|
|
use Kahlan\Matcher;
|
|
use Kahlan\Cli\Kahlan;
|
|
|
|
$box = box('kahlan', new Box());
|
|
|
|
$box->service('suite.global', function() {
|
|
return new Suite();
|
|
});
|
|
|
|
$specs = new Kahlan([
|
|
'autoloader' => reset($autoloaders),
|
|
'suite' => $box->get('suite.global')
|
|
]);
|
|
$specs->loadConfig($argv);
|
|
$specs->run();
|
|
exit($specs->status());
|