mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Simplify builder service
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Command\Developer;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
@@ -51,10 +52,10 @@ class LessCompiler extends Command
|
||||
|
||||
$output->writeln('Building Assets...');
|
||||
|
||||
$errors = $this->container['phraseanet.less-builder']->build($files);
|
||||
|
||||
if (count($errors) > 0) {
|
||||
$output->writeln(sprintf('<error>Errors occured during the build %s</error>', implode(', ', $errors)));
|
||||
try {
|
||||
$this->container['phraseanet.less-builder']->build($files);
|
||||
} catch (RuntimeException $e) {
|
||||
$output->writeln(sprintf('<error>Could not build less files %s</error>', implode(', ', $e->getMessage())));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@@ -44,11 +44,12 @@ abstract class AbstractPluginCommand extends Command
|
||||
);
|
||||
|
||||
$output->write('Building Assets...');
|
||||
$errors = $this->container['phraseanet.less-builder']->build($files);
|
||||
|
||||
if (count($errors) > 0) {
|
||||
$output->writeln(sprintf('<error>Error(s) occured during the build %s</error>', implode(', ', $errors)));
|
||||
try {
|
||||
$this->container['phraseanet.less-builder']->build($files);
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
} catch (RuntimeException $e) {
|
||||
$output->writeln(sprintf('<error>Could not build less files %s</error>', implode(', ', $e->getMessage())));
|
||||
}
|
||||
$output->writeln(" <comment>OK</comment>");
|
||||
}
|
||||
}
|
||||
|
@@ -38,20 +38,9 @@ class Builder
|
||||
*/
|
||||
public function build($files)
|
||||
{
|
||||
$failures = 0;
|
||||
$errors = array();
|
||||
|
||||
foreach ($files as $lessFile => $target) {
|
||||
$this->filesystem->mkdir(dirname($target));
|
||||
|
||||
try {
|
||||
$this->compiler->compile($target, $lessFile);
|
||||
} catch (\Exception $e) {
|
||||
$failures++;
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
$this->compiler->compile($target, $lessFile);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
@@ -36,6 +36,14 @@ class Compiler
|
||||
return new self($app['filesystem'], RecessDriver::create($binaries));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile LESS files
|
||||
*
|
||||
* @param string $target
|
||||
* @param string $files
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function compile($target, $files)
|
||||
{
|
||||
$this->filesystem->mkdir(dirname($target));
|
||||
|
@@ -27,8 +27,6 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$builder = new Builder($compiler, $filesystem);
|
||||
|
||||
$build = $builder->build(array( __FILE__ => __DIR__ . '/output.css'));
|
||||
|
||||
$this->assertTrue($build);
|
||||
$builder->build(array( __FILE__ => __DIR__ . '/output.css'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user