Skip to content

Commit 42f69ce

Browse files
committed
make tests cleanup deletable dirs in test/
Signed-off-by: Kipras Melnikovas <[email protected]>
1 parent df197e3 commit 42f69ce

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

test/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
folders-to-delete
22
.tmp
3+
.tmp-*

test/setupRepo.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ export async function setupRepo({
109109
const dir: string = createTmpdir(tmpdir);
110110

111111
const foldersToDeletePath: string = path.join(__dirname, "folders-to-delete");
112+
if (!fs.existsSync(foldersToDeletePath)) {
113+
fs.writeFileSync(foldersToDeletePath, "");
114+
}
115+
const deletables = fs.readFileSync(foldersToDeletePath, { encoding: "utf-8" }).split("\n");
116+
for (const d of deletables) {
117+
if (fs.existsSync(d)) {
118+
fs.rmdirSync(d, { recursive: true });
119+
}
120+
}
112121
fs.appendFileSync(foldersToDeletePath, dir + "\n", { encoding: "utf-8" });
113122

114123
/**

0 commit comments

Comments
 (0)