feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Checkpoint
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs/promises");
|
||||
const { RR_ACTIONS, RR_SOAP_HEADERS } = require("./rr-constants");
|
||||
const mustache = require("mustache");
|
||||
|
||||
// ---- Action <-> Template wiring ----
|
||||
// Keep action names consistent with rr-helpers / rr-lookup / rr-repair-orders / rr-customer
|
||||
@@ -84,9 +85,12 @@ async function verifyTemplatesExist() {
|
||||
for (const [action, tpl] of Object.entries(ACTION_TEMPLATES)) {
|
||||
const filePath = path.join(baseDir, `${tpl}.xml`);
|
||||
try {
|
||||
const stat = await fs.stat(filePath);
|
||||
if (!stat.isFile()) {
|
||||
issues.push({ action, template: tpl, error: "Not a regular file" });
|
||||
const contents = await fs.readFile(filePath, "utf8"); // throws if missing
|
||||
try {
|
||||
// Parse-only to catch “Unclosed section …” and similar
|
||||
mustache.parse(contents);
|
||||
} catch (parseErr) {
|
||||
issues.push({ action, template: tpl, error: `Mustache parse error: ${parseErr.message}`, filePath });
|
||||
}
|
||||
} catch {
|
||||
issues.push({ action, template: tpl, error: `Missing file: ${filePath}` });
|
||||
@@ -94,7 +98,6 @@ async function verifyTemplatesExist() {
|
||||
}
|
||||
return issues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick assert that throws if any template is missing.
|
||||
* You can call this once during boot and log the result.
|
||||
|
||||
Reference in New Issue
Block a user