File size: 704 Bytes
e81f4e4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import { classifyChangedFiles } from "./ci-change-risk.mjs";
import { outputLine } from "./io.mjs";
const files = process.env.CI_CHANGED_FILES_JSON
? JSON.parse(process.env.CI_CHANGED_FILES_JSON)
: await readNullSeparatedStdin();
const risk = classifyChangedFiles(Array.isArray(files) ? files : []);
outputLine(risk);
if (process.env.GITHUB_OUTPUT) {
const { appendFile } = await import("node:fs/promises");
await appendFile(
process.env.GITHUB_OUTPUT,
`risk=${risk}\nruntime=${risk === "runtime"}\n`,
);
}
async function readNullSeparatedStdin() {
const chunks = [];
for await (const chunk of process.stdin) chunks.push(chunk);
return Buffer.concat(chunks).toString("utf8").split("\0");
}
|