Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 35 additions & 13 deletions src/Processor/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,47 @@ public function processFile(FileContainer $file)
{
switch ($file->getType()) {
case FileContainer::TYPE_SCSS:
try {
$this->sass->addImportPath(dirname($file->getInputPath()));
$content = $this->sass->compile($file->getInputContent());

return $file->setOutputContent($content);
} catch (ParserException $e) {
throw new CompilerException($e->getMessage(), 1, $e);
}
return $this->compileSCSS($file);
case FileContainer::TYPE_LESS:
try {
return $file->setOutputContent($this->less->compileFile($file->getInputPath()));
} catch (\Exception $e) {
throw new CompilerException($e->getMessage(), 1, $e);
}
return $this->compileLESS($file);
}

throw new CompilerException('unknown compiler');
}

/**
* @param FileContainer $file
*
* @return $this
* @throws CompilerException
*/
protected function compileSCSS(FileContainer $file)
{
try {
$this->sass->addImportPath(dirname($file->getInputPath()));
$content = $this->sass->compile($file->getInputContent());

return $file->setOutputContent($content);
} catch (ParserException $e) {
throw new CompilerException($e->getMessage(), 1, $e);
}
}

/**
* @param FileContainer $file
*
* @return $this
* @throws CompilerException
*/
protected function compileLESS(FileContainer $file)
{
try {
return $file->setOutputContent($this->less->compileFile($file->getInputPath()));
} catch (\Exception $e) {
throw new CompilerException($e->getMessage(), 1, $e);
}
}

/**
* @param string $formatter
*
Expand Down