diff --git a/php/generate-html.php b/php/generate-html.php index 638a48b..9034ccc 100644 --- a/php/generate-html.php +++ b/php/generate-html.php @@ -30,15 +30,22 @@ $relpath = str_replace($TEMPLATES_ROOT, "", $phppath); $docpath = str_replace(".php", ".html", $docpath); - // This works? Yes, yes it does. // We do this to isolate the environment and include-once triggers, // otherwise we could include the documents in an ob_* wrapper. - // Same as shell_exec, except we don't have to escape quotes. log_info("Generating output for $relpath."); - $document = `cd "$TEMPLATES_ROOT"; php $phppath $flags`; + $output = []; - file_put_contents($docpath, $document); + $exit_code = 0; + + exec("cd '$TEMPLATES_ROOT'; php '$phppath' $flags", $output, $exit_code); + + if ($exit_code != 0 || empty($output)) { + log_error("HTML generation failed."); + exit(255); + } + + file_put_contents($docpath, join("\n", $output)); } log_info("Done generating HTML.");