Skip to content

Commit

Permalink
error when no files will be processed (#4326)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jun 26, 2023
1 parent 715561c commit 3ca5734
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,8 @@ public function addFilesByDirectory(string $directory, array $files): void

$this->filesByDirectory[$directory] = $files;
}

public function isPathsEmpty(): bool {
return $this->filePaths === [] && $this->filesByDirectory === [];
}
}
4 changes: 4 additions & 0 deletions src/Console/Command/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ 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->rectorOutputStyle->error("The given paths do not match any files");
return ExitCode::FAILURE;
}

// 2. inform user about registering configurable rule without configuration
$this->emptyConfigurableRectorChecker->check();
Expand Down
4 changes: 4 additions & 0 deletions src/StaticReflection/DynamicSourceLocatorDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ public function addPaths(array $paths): void
$this->dynamicSourceLocatorProvider->addFilesByDirectory($directory, $filesInDirectory);
}
}

public function isPathsEmpty(): bool {
return $this->dynamicSourceLocatorProvider->isPathsEmpty();
}
}

0 comments on commit 3ca5734

Please sign in to comment.