Skip to content
Merged
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
7 changes: 6 additions & 1 deletion actions/setup/js/sanitize_output.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,13 @@ const mockCore = {
}),
describe("main function", () => {
(beforeEach(() => {
const testDir = "/tmp/gh-aw";
const testFile = "/tmp/gh-aw/test-output.txt";
(fs.existsSync(testFile) && fs.unlinkSync(testFile), (global.fs = fs));
if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}
Comment on lines +322 to +324
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.mkdirSync(testDir, { recursive: true }) is already idempotent when the directory exists, so the existsSync guard is redundant and introduces a minor TOCTOU pattern. Consider calling mkdirSync unconditionally (still with { recursive: true }) to simplify the setup logic.

Suggested change
if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}
fs.mkdirSync(testDir, { recursive: true });

Copilot uses AI. Check for mistakes.
fs.existsSync(testFile) && fs.unlinkSync(testFile);
global.fs = fs;
}),
afterEach(() => {
delete global.fs;
Expand Down
Loading