Add whitelist to the classmap generator to allow skipping of Test files
parent
48c46ce3b6
commit
ee14950972
|
@ -121,7 +121,12 @@ EOF;
|
|||
foreach ($autoloads['psr-0'] as $namespace => $paths) {
|
||||
foreach ($paths as $dir) {
|
||||
$dir = $this->getPath($filesystem, $relVendorPath, $vendorPath, $dir);
|
||||
foreach (ClassMapGenerator::createMap($dir) as $class => $path) {
|
||||
$whitelist = sprintf(
|
||||
'{%s/%s.+(?<!(?<!/)Test\.php)$}',
|
||||
preg_quote(rtrim($dir, '/')),
|
||||
strpos($namespace, '_') === false ? preg_quote(strtr($namespace, '\\', '/')) : ''
|
||||
);
|
||||
foreach (ClassMapGenerator::createMap($dir, $whitelist) as $class => $path) {
|
||||
if (0 === strpos($class, $namespace)) {
|
||||
$path = '/'.$filesystem->findShortestPath(getcwd(), $path, true);
|
||||
if (!isset($classMap[$class])) {
|
||||
|
@ -304,7 +309,7 @@ EOF;
|
|||
// path starts with vendor dir
|
||||
return $vendorPath . substr($path, strlen($relVendorPath));
|
||||
}
|
||||
return getcwd().'/'.$path;
|
||||
return strtr(getcwd(), '\\', '/').'/'.$path;
|
||||
}
|
||||
|
||||
return $path;
|
||||
|
|
|
@ -41,10 +41,11 @@ class ClassMapGenerator
|
|||
* Iterate over all files in the given directory searching for classes
|
||||
*
|
||||
* @param Iterator|string $dir The directory to search in or an iterator
|
||||
* @param string $whitelist Regex that matches against the file path
|
||||
*
|
||||
* @return array A class map array
|
||||
*/
|
||||
public static function createMap($dir)
|
||||
public static function createMap($dir, $whitelist = null)
|
||||
{
|
||||
if (is_string($dir)) {
|
||||
if (is_file($dir)) {
|
||||
|
@ -67,6 +68,10 @@ class ClassMapGenerator
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($whitelist && !preg_match($whitelist, strtr($path, '\\', '/'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classes = self::findClasses($path);
|
||||
|
||||
foreach ($classes as $class) {
|
||||
|
|
Loading…
Reference in New Issue