refactor: fix exit-1 comment, remove JSON round-trip, use OfficeMeta cast

This commit is contained in:
jiayiyan
2026-05-18 16:41:37 +08:00
parent 6d069c955f
commit ed728b2ad9
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
import { END, type ModeratorCondition, type ModeratorTable, START } from "@uncaged/workflow-runtime"; import { END, type ModeratorCondition, type ModeratorTable, START } from "@uncaged/workflow-runtime";
import type { DocumentEditorMeta } from "./roles.js"; import type { DocumentEditorMeta, OfficeMeta } from "./roles.js";
const officeIsEdit: ModeratorCondition<DocumentEditorMeta> = { const officeIsEdit: ModeratorCondition<DocumentEditorMeta> = {
name: "officeIsEdit", name: "officeIsEdit",
@@ -7,7 +7,7 @@ const officeIsEdit: ModeratorCondition<DocumentEditorMeta> = {
check: (ctx) => { check: (ctx) => {
const officeStep = ctx.steps.find((s) => s.role === "office"); const officeStep = ctx.steps.find((s) => s.role === "office");
if (officeStep === undefined) return false; if (officeStep === undefined) return false;
return (officeStep.meta as { mode: string }).mode === "edit"; return (officeStep.meta as OfficeMeta).mode === "edit";
}, },
}; };
+2 -2
View File
@@ -37,6 +37,7 @@ export function createDifferAdapter(
if (!result.ok) { if (!result.ok) {
const e = result.error; const e = result.error;
if (e.kind === "non_zero_exit" && e.exitCode === 1) { if (e.kind === "non_zero_exit" && e.exitCode === 1) {
// docx-diff exits 1 when documents have differences — this is a success path
} else if (e.kind === "non_zero_exit") { } else if (e.kind === "non_zero_exit") {
throw new Error(`differ: docx-diff failed (exit ${e.exitCode}): ${e.stderr}`); throw new Error(`differ: docx-diff failed (exit ${e.exitCode}): ${e.stderr}`);
} else if (e.kind === "timeout") { } else if (e.kind === "timeout") {
@@ -52,8 +53,7 @@ export function createDifferAdapter(
throw new Error(`differ: report file not found: ${reportPath}`); throw new Error(`differ: report file not found: ${reportPath}`);
} }
const raw = JSON.stringify({ outputDocx, sourceDocx, diffReport: reportPath }); const meta = schema.parse({ outputDocx, sourceDocx, diffReport: reportPath });
const meta = schema.parse(JSON.parse(raw)) as T;
return { meta, childThread: null }; return { meta, childThread: null };
}; };
} }