diff --git a/build/license.php b/build/license.php index ce6fceb8160..9a2495683c2 100644 --- a/build/license.php +++ b/build/license.php @@ -48,17 +48,25 @@ EOD; $this->licenseText = str_replace('@YEAR@', date("Y"), $this->licenseText); } - function exec($folder) { + /** + * @param string|string[] $folder + * @param string|bool $gitRoot + */ + function exec($folder, $gitRoot = false) { if (is_array($folder)) { foreach($folder as $f) { - $this->exec($f); + $this->exec($f, $gitRoot); } return; } + if ($gitRoot !== false && substr($gitRoot, -1) !== '/') { + $gitRoot .= '/'; + } + if (is_file($folder)) { - $this->handleFile($folder); + $this->handleFile($folder, $gitRoot); return; } @@ -81,7 +89,7 @@ EOD; foreach ($iterator as $file) { /** @var SplFileInfo $file */ - $this->handleFile($file); + $this->handleFile($file, $gitRoot); } } @@ -103,14 +111,14 @@ With help from many libraries and frameworks including: file_put_contents(__DIR__.'/../AUTHORS', $template); } - function handleFile($path) { + function handleFile($path, $gitRoot) { $source = file_get_contents($path); if ($this->isMITLicensed($source)) { echo "MIT licensed file: $path" . PHP_EOL; return; } $source = $this->eatOldLicense($source); - $authors = $this->getAuthors($path); + $authors = $this->getAuthors($path, $gitRoot); $license = str_replace('@AUTHORS@', $authors, $this->licenseText); $source = "exec($argv[1]); + $licenses->exec($argv[1], isset($argv[2]) ? $argv[1] : false); } else { $licenses->exec([ '../apps/dav',