filesystem = $filesystem; $this->recess = $recess; } /** * Compile LESS files * * @param string $target * @param string $files * * @throws RuntimeException */ public function compile($target, $files) { $this->filesystem->mkdir(dirname($target)); if (!$files instanceof \Traversable) { $files = new \ArrayObject(is_array($files) ? $files : [$files]); } $files = (array) $files; foreach ($files as $file) { if (false === is_file($file)) { throw new RuntimeException($file . ' does not exists.'); } } if (!is_writable(dirname($target))) { throw new RuntimeException(dirname($target) . ' is not writable.'); } $commands = $files; array_unshift($commands, '--compile'); try { $output = $this->recess->command($commands); $this->filesystem->dumpFile($target, $output); } catch (ExecutionFailureException $e) { throw new RuntimeException('Could not execute recess command.', $e->getCode(), $e); } } }