filesystem = $filesystem ?: new Filesystem(); } public function compile($target, $files) { $this->filesystem->mkdir(dirname($target)); if (!$files instanceof \Traversable) { $files = new \ArrayObject(is_array($files) ? $files : array($files)); } $files = new ArrayCollection((array) $files); if ($files->forAll(function($file) { return is_file($file); })) { throw new RuntimeException(realpath($files) . ' does not exists.'); } if (!is_writable(dirname($target))) { throw new RuntimeException(realpath(dirname($target)) . ' is not writable.'); } $builder = ProcessBuilder::create(array_merge(array( 'recess', '--compile' ), $files->toArray())); $process = $builder->getProcess(); $process->run(); if (!$process->isSuccessful()) { throw new RuntimeException(sprintf('An errord occured during the build %s', $process->getErrorOutput())); } $this->filesystem->dumpFile($target, $process->getOutput()); } }