mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-26 20:53:31 +00:00
bin/rector: allow custom config
This commit is contained in:
parent
01d5d397e1
commit
404e5a9837
|
@ -1,7 +1,10 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Rector\Console\Application;
|
||||
use Rector\DependencyInjection\ContainerFactory;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symplify\PackageBuilder\Configuration\ConfigFilePathHelper;
|
||||
use Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
|
||||
|
||||
// Performance boost
|
||||
gc_disable();
|
||||
|
@ -9,10 +12,29 @@ gc_disable();
|
|||
// Require Composer autoload.php
|
||||
require_once __DIR__ . '/bootstrap.php';
|
||||
|
||||
// Build DI container
|
||||
$container = (new ContainerFactory)->create();
|
||||
|
||||
// Run Console Application
|
||||
/** @var Application $application */
|
||||
$application = $container->get(Application::class);
|
||||
$application->run();
|
||||
try {
|
||||
// 1. Detect configuration
|
||||
ConfigFilePathHelper::detectFromInput('rector', new ArgvInput);
|
||||
|
||||
// 2. Build DI container
|
||||
$containerFactory = new ContainerFactory;
|
||||
$configFile = ConfigFilePathHelper::provide('rector', 'rector.yml');
|
||||
|
||||
if ($configFile) {
|
||||
$container = $containerFactory->createWithConfig($configFile);
|
||||
} else {
|
||||
$container = $containerFactory->create();
|
||||
}
|
||||
|
||||
// 3. Run Console Application
|
||||
/** @var Application $application */
|
||||
$application = $container->get(Application::class);
|
||||
$statusCode = $application->run();
|
||||
exit($statusCode);
|
||||
|
||||
} catch (Throwable $throwable) {
|
||||
$symfonyStyle = SymfonyStyleFactory::create();
|
||||
$symfonyStyle->error($throwable->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user