Skip to content

Commit

Permalink
error when no files will be processed
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jun 23, 2023
1 parent 1d012e4 commit 5e76f39
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 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 === [];
}
}
5 changes: 4 additions & 1 deletion src/Console/Command/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$paths = $configuration->getPaths();

// 1. add files and directories to static locator
$this->dynamicSourceLocatorDecorator->addPaths($paths);
if ($this->dynamicSourceLocatorDecorator->addPaths($paths) === false) {
$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
6 changes: 4 additions & 2 deletions src/StaticReflection/DynamicSourceLocatorDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public function __construct(
/**
* @param string[] $paths
*/
public function addPaths(array $paths): void
public function addPaths(array $paths): bool
{
if ($paths === []) {
return;
return false;
}

$files = $this->fileAndDirectoryFilter->filterFiles($paths);
Expand All @@ -38,5 +38,7 @@ public function addPaths(array $paths): void
$filesInDirectory = $this->phpFilesFinder->findInPaths([$directory]);
$this->dynamicSourceLocatorProvider->addFilesByDirectory($directory, $filesInDirectory);
}

return !$this->dynamicSourceLocatorProvider->isPathsEmpty();
}
}

0 comments on commit 5e76f39

Please sign in to comment.