ComponentInstaller\Process\RequireJsProcess::aggregateScripts PHP Method

aggregateScripts() public method

Concatenate all scripts together into one destination file.
public aggregateScripts ( array $package, array $scripts, string $file ) : boolean
$package array
$scripts array
$file string
return boolean
    public function aggregateScripts($package, array $scripts, $file)
    {
        $assets = $this->newAssetCollection();
        foreach ($scripts as $script) {
            // Collect each candidate from a glob file search.
            $path = $this->getVendorDir($package) . DIRECTORY_SEPARATOR . $script;
            $matches = $this->fs->recursiveGlobFiles($path);
            foreach ($matches as $match) {
                $assets->add(new FileAsset($match));
            }
        }
        $js = $assets->dump();
        // Write the file if there are any JavaScript assets.
        if (!empty($js)) {
            $destination = $this->componentDir . DIRECTORY_SEPARATOR . $file;
            $this->fs->ensureDirectoryExists(dirname($destination));
            return file_put_contents($destination, $js);
        }
        return false;
    }