diff --git a/actions/setup/js/copilot_driver.cjs b/actions/setup/js/copilot_driver.cjs index a66511be843..e0bf2c038c8 100644 --- a/actions/setup/js/copilot_driver.cjs +++ b/actions/setup/js/copilot_driver.cjs @@ -62,15 +62,7 @@ const MODEL_NOT_SUPPORTED_PATTERN = /The requested model is not supported/; const NO_AUTH_INFO_PATTERN = /No authentication information found/; /** - * @typedef {(path: import("node:fs").PathOrFileDescriptor, data: string | Uint8Array, options?: import("node:fs").WriteFileOptions) => void} NodeAppendFileSync - */ - -/** - * @typedef {(path: string, data: string, encoding: string) => void} StringAppendLineWriter - */ - -/** - * @typedef {NodeAppendFileSync | StringAppendLineWriter} AppendFileSyncLike + * @typedef {(path: import("node:fs").PathOrFileDescriptor, data: string | Uint8Array, options?: import("node:fs").WriteFileOptions) => void} AppendFileSyncLike */ /** @@ -154,7 +146,7 @@ function buildInfrastructureIncompletePayload(details) { * @param {string} payload */ function appendSafeOutputLine(appendFileSync, safeOutputsPath, payload) { - appendFileSync(safeOutputsPath, payload + "\n", "utf8"); + appendFileSync(safeOutputsPath, payload + "\n", { encoding: "utf8" }); } /** diff --git a/actions/setup/js/copilot_driver.test.cjs b/actions/setup/js/copilot_driver.test.cjs index 367c39c53e4..7ee562823be 100644 --- a/actions/setup/js/copilot_driver.test.cjs +++ b/actions/setup/js/copilot_driver.test.cjs @@ -151,9 +151,9 @@ describe("copilot_driver.cjs", () => { it("appends one JSONL line through appendSafeOutputLine", () => { const writes = []; - const appendStub = (file, data, encoding) => writes.push({ file, data, encoding }); + const appendStub = (file, data, options) => writes.push({ file, data, options }); appendSafeOutputLine(appendStub, "/tmp/safeoutputs.jsonl", '{"type":"report_incomplete"}'); - expect(writes).toEqual([{ file: "/tmp/safeoutputs.jsonl", data: '{"type":"report_incomplete"}\n', encoding: "utf8" }]); + expect(writes).toEqual([{ file: "/tmp/safeoutputs.jsonl", data: '{"type":"report_incomplete"}\n', options: { encoding: "utf8" } }]); }); it("emitInfrastructureIncomplete writes payload when path is configured", () => { @@ -161,7 +161,7 @@ describe("copilot_driver.cjs", () => { const logs = []; emitInfrastructureIncomplete("temporary outage", { safeOutputsPath: "/tmp/safeoutputs.jsonl", - appendFileSync: (file, data, encoding) => writes.push({ file, data, encoding }), + appendFileSync: (file, data, options) => writes.push({ file, data, options }), logger: message => logs.push(message), }); expect(writes).toHaveLength(1);