Propagate failure in HTML generation

dev
gravel 2 years ago
parent bee544dab8
commit 3fea99f6f2
Signed by: gravel
GPG Key ID: C0538F3C906B308F

@ -30,15 +30,22 @@
$relpath = str_replace($TEMPLATES_ROOT, "", $phppath); $relpath = str_replace($TEMPLATES_ROOT, "", $phppath);
$docpath = str_replace(".php", ".html", $docpath); $docpath = str_replace(".php", ".html", $docpath);
// This works? Yes, yes it does.
// We do this to isolate the environment and include-once triggers, // We do this to isolate the environment and include-once triggers,
// otherwise we could include the documents in an ob_* wrapper. // 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."); 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."); log_info("Done generating HTML.");

Loading…
Cancel
Save