schema: fix log generation

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2021-06-01 13:00:27 +02:00
parent ba86a149b8
commit f7c2d39c98

View File

@@ -17,12 +17,15 @@ inputfile.close();
let logs = [];
try {
let batch = renderer.render(schemareader.validate(inputjson), logs);
let state = schemareader.validate(inputjson, logs);
let batch = state ? renderer.render(state, logs) : "";
fs.stdout.write("Log messages:\n" + join("\n", logs) + "\n\n");
fs.stdout.write("UCI batch output:\n" + batch + "\n");
if (state) {
let outputjson = fs.open("/tmp/ucentral.uci", "w");
outputjson.write(batch);
outputjson.close();
@@ -43,7 +46,9 @@ try {
fs.unlink('/etc/ucentral/ucentral.active');
fs.symlink(ARGV[2], '/etc/ucentral/ucentral.active');
} else {
error = 1;
}
}
catch (e) {
error = 1;