Skip to content

Commit

Permalink
[DX] Show paths not match any file/directory on ProcessCommand when g…
Browse files Browse the repository at this point in the history
…iven path not exists (#6307)

* [DX] Show paths not match any file/directory on ProcessCommand when given path not exists

* no paths check

* no paths check

* no paths check

* [ci-review] Rector Rectify

* no paths check

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Sep 16, 2024
1 parent db5688c commit 04bd2bb
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Console/Command/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,29 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// 1. add files and directories to static locator
$this->dynamicSourceLocatorDecorator->addPaths($paths);
if ($this->dynamicSourceLocatorDecorator->isPathsEmpty()) {
$this->symfonyStyle->error('The given paths do not match any files');
// read from rector.php, no paths definition needs withPaths() config
if ($paths === []) {
$this->symfonyStyle->error(
'No paths definition in rector configuration, define paths: https://getrector.com/documentation/define-paths'
);

return ExitCode::FAILURE;
}

// read from cli paths arguments, eg: vendor/bin/rector process A B C which A, B, and C not exists
$isSingular = count($paths) === 1;
$this->symfonyStyle->error(
sprintf(
'The following given path%s do%s not match any file%s or director%s: %s%s',
$isSingular ? '' : 's',
$isSingular ? 'es' : '',
$isSingular ? '' : 's',
$isSingular ? 'y' : 'ies',
PHP_EOL . PHP_EOL . ' - ',
implode(PHP_EOL . ' - ', $paths)
)
);

return ExitCode::FAILURE;
}

Expand Down

0 comments on commit 04bd2bb

Please sign in to comment.