diff --git a/lib/Alchemy/Phrasea/Command/Developer/LessCompiler.php b/lib/Alchemy/Phrasea/Command/Developer/LessCompiler.php index 3fa29f0c94..7a59c8ef21 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/LessCompiler.php +++ b/lib/Alchemy/Phrasea/Command/Developer/LessCompiler.php @@ -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('Errors occured during the build %s', implode(', ', $errors))); + try { + $this->container['phraseanet.less-builder']->build($files); + } catch (RuntimeException $e) { + $output->writeln(sprintf('Could not build less files %s', implode(', ', $e->getMessage()))); return 1; } diff --git a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php index f3bec54a1f..f9b8850335 100644 --- a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php +++ b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php @@ -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(s) occured during the build %s', implode(', ', $errors))); + + try { + $this->container['phraseanet.less-builder']->build($files); + $output->writeln(" OK"); + } catch (RuntimeException $e) { + $output->writeln(sprintf('Could not build less files %s', implode(', ', $e->getMessage()))); } - $output->writeln(" OK"); } } diff --git a/lib/Alchemy/Phrasea/Utilities/Less/Builder.php b/lib/Alchemy/Phrasea/Utilities/Less/Builder.php index 607f1c950a..06091a07ea 100644 --- a/lib/Alchemy/Phrasea/Utilities/Less/Builder.php +++ b/lib/Alchemy/Phrasea/Utilities/Less/Builder.php @@ -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; } } diff --git a/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php b/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php index 5047546f09..f87a475638 100644 --- a/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php +++ b/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php @@ -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)); diff --git a/tests/Alchemy/Tests/Phrasea/Utilities/Less/BuilderTest.php b/tests/Alchemy/Tests/Phrasea/Utilities/Less/BuilderTest.php index 811a0e761e..3623d42c2e 100644 --- a/tests/Alchemy/Tests/Phrasea/Utilities/Less/BuilderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Utilities/Less/BuilderTest.php @@ -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')); } }