Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions actions/setup/js/copilot_driver.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

/**
Expand Down Expand Up @@ -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" });
}

/**
Expand Down
6 changes: 3 additions & 3 deletions actions/setup/js/copilot_driver.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ 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", () => {
const writes = [];
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);
Expand Down
Loading