Permalink
Browse files

Handle files that are passed as directories correctly.

  • Loading branch information...
1 parent 8d0ff72 commit bcee6255363acb81ce2f41eaa45b4bd18a12939c @sebastianbergmann committed Feb 4, 2012
Showing with 15 additions and 7 deletions.
  1. +15 −7 PHPDCD/TextUI/Command.php
View
@@ -239,11 +239,18 @@ protected function printVersionString()
*/
protected function findFiles(array $directories, array $excludes, array $suffixes)
{
- $finder = new Symfony\Component\Finder\Finder;
+ $files = array();
+ $finder = new Symfony\Component\Finder\Finder;
+ $iterate = FALSE;
try {
foreach ($directories as $directory) {
- $finder->in($directory);
+ if (!is_file($directory)) {
+ $finder->in($directory);
+ $iterate = TRUE;
+ } else {
+ $files[] = realpath($directory);
+ }
}
foreach ($excludes as $exclude) {
@@ -256,13 +263,14 @@ protected function findFiles(array $directories, array $excludes, array $suffixe
}
catch (Exception $e) {
- $this->showError($e->getMessage());
+ $this->showError($e->getMessage() . "\n");
+ exit(1);
}
- $files = array();
-
- foreach ($finder as $file) {
- $files[] = $file->getRealpath();
+ if ($iterate) {
+ foreach ($finder as $file) {
+ $files[] = $file->getRealpath();
+ }
}
return $files;

0 comments on commit bcee625

Please sign in to comment.