public function process()
{
// Construct the require.js and stick it in the destination.
$json = $this->requireJson($this->packages, $this->config);
$requireConfig = $this->requireJs($json);
// Attempt to write the require.config.js file.
$destination = $this->componentDir . '/require.config.js';
$this->fs->ensureDirectoryExists(dirname($destination));
if (file_put_contents($destination, $requireConfig) === FALSE) {
$this->io->write('<error>Error writing require.config.js</error>');
return false;
}
// Read in require.js to prepare the final require.js.
if (!file_exists(dirname(__DIR__) . '/Resources/require.js')) {
$this->io->write('<error>Error reading in require.js</error>');
return false;
}
$assets = $this->newAssetCollection();
$assets->add(new StringAsset($requireConfig));
$assets->add(new FileAsset(dirname(__DIR__) . '/Resources/require.js'));
// Append the config to the require.js and write it.
if (file_put_contents($this->componentDir . '/require.js', $assets->dump()) === FALSE) {
$this->io->write('<error>Error writing require.js to the components directory</error>');
return false;
}
return null;
}