Skip to content

Commit

Permalink
Fixed 2 recursion issues
Browse files Browse the repository at this point in the history
close #3
  • Loading branch information
bigmacfoobar authored and cebe committed May 6, 2015
1 parent c85c42d commit db80779
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bin/jsindex
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ if (empty($src)) {

$indexer = new \cebe\jssearch\Indexer();

$files = [];
foreach($src as $dir) {
$files = array_merge($files, findFiles($dir));
echo "Processing $dir\n";
$files = findFiles($dir);

if (empty($files)) {
error("No files where found in $dir.");
echo "No files where found in $dir.\n";
} else {
$indexer->indexFiles($files, $dir);
}

$indexer->indexFiles($files, $dir);
}

$js = $indexer->exportJs();
Expand Down Expand Up @@ -119,15 +119,15 @@ function findFiles($dir, $ext = '.html')
continue;
}
$path = $dir . DIRECTORY_SEPARATOR . $file;
if (substr($file, -($l = strlen($ext)), $l) === $ext) {
if (is_file($path)) {
if (is_file($path)) {
if (substr($file, -($l = strlen($ext)), $l) === $ext) {
$list[] = $path;
} else {
$list = array_merge($list, findFiles($path, $ext));
}
} else {
$list = array_merge($list, findFiles($path, $ext));
}
}
closedir($handle);

return $list;
}
}

0 comments on commit db80779

Please sign in to comment.