25 lines
658 B
PHP
25 lines
658 B
PHP
#!/usr/bin/env php
|
|
<?php
|
|
|
|
$target = __DIR__.'/../vendor/bin/rector';
|
|
|
|
// Get arguments from CLI
|
|
$args = $argv;
|
|
array_shift($args); // Remove script name
|
|
|
|
// Add --ansi to keep colored output
|
|
$args[] = '--ansi';
|
|
|
|
$hasConfigArg = (bool) array_filter($args, fn ($arg) => str_starts_with($arg, '--config=') || str_starts_with($arg, '--c'));
|
|
// Config option is not set, so use default rector config
|
|
if (!$hasConfigArg) {
|
|
$args[] = '--config="'.__DIR__.'/../rector.php'.'"';
|
|
}
|
|
|
|
// Build the final command
|
|
$command = escapeshellcmd($target) . ' ' . implode(' ', $args);
|
|
|
|
// Run the command and passthrough output
|
|
passthru($command, $exitCode);
|
|
exit($exitCode);
|