fix(test): stabilize core runtime infra shard

This commit is contained in:
Vincent Koc
2026-04-28 17:30:44 -07:00
parent 7229ec5e04
commit 8e5fcfff50
2 changed files with 14 additions and 2 deletions

View File

@@ -98,6 +98,9 @@ function getColorForConsole(): ChalkInstance {
typeof process.env.FORCE_COLOR === "string" &&
process.env.FORCE_COLOR.trim().length > 0 &&
process.env.FORCE_COLOR.trim() !== "0";
if (hasForceColor) {
return new Chalk({ level: 1 });
}
if (process.env.NO_COLOR && !hasForceColor) {
return new Chalk({ level: 0 });
}

View File

@@ -12,8 +12,17 @@ import {
async function writeSecureFile(filePath: string, content: string, mode = 0o600): Promise<void> {
await fs.mkdir(path.dirname(filePath), { recursive: true });
await fs.writeFile(filePath, content, "utf8");
await fs.chmod(filePath, mode);
const tempPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random()
.toString(16)
.slice(2)}`;
try {
await fs.writeFile(tempPath, content, "utf8");
await fs.chmod(tempPath, mode);
await fs.rename(tempPath, filePath);
} catch (err) {
await fs.rm(tempPath, { force: true }).catch(() => {});
throw err;
}
}
describe("secret ref resolver", () => {