make sure target directory exists
This commit is contained in:
@@ -214,9 +214,6 @@ class TemplateService
|
|||||||
*/
|
*/
|
||||||
public function render(string $template, DataCollectorInterface $data, string $destDir): string
|
public function render(string $template, DataCollectorInterface $data, string $destDir): string
|
||||||
{
|
{
|
||||||
if (!is_dir($destDir)) {
|
|
||||||
mkdir($destDir, 0755, true);
|
|
||||||
}
|
|
||||||
$vars = $data->getData();
|
$vars = $data->getData();
|
||||||
$name = isset($vars['name']) ? $vars['name'] : $this->docname;
|
$name = isset($vars['name']) ? $vars['name'] : $this->docname;
|
||||||
$name .= isset($vars['theme']) ? '.'.$vars['theme'] : '';
|
$name .= isset($vars['theme']) ? '.'.$vars['theme'] : '';
|
||||||
@@ -224,6 +221,10 @@ class TemplateService
|
|||||||
|
|
||||||
$html = $this->twig->render($template, $vars);
|
$html = $this->twig->render($template, $vars);
|
||||||
$html = $this->minifier->minify($html);
|
$html = $this->minifier->minify($html);
|
||||||
|
|
||||||
|
if (!is_dir(dirname($path))) {
|
||||||
|
mkdir(dirname($path), 0755, true);
|
||||||
|
}
|
||||||
if (!file_put_contents($path, $html)) {
|
if (!file_put_contents($path, $html)) {
|
||||||
throw new \RuntimeException('Error writing output file: '.$path);
|
throw new \RuntimeException('Error writing output file: '.$path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user