Skip to content

Commit 7afb2f7

Browse files
authored
Fix: Temporary files created by the test are not removed. (#14573)
* fix * review
1 parent 1e08968 commit 7afb2f7

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

packages/babel-core/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
"@types/convert-source-map": "^1.5.1",
7272
"@types/debug": "^4.1.0",
7373
"@types/resolve": "^1.3.2",
74-
"@types/semver": "^5.4.0"
74+
"@types/semver": "^5.4.0",
75+
"rimraf": "^3.0.0"
7576
},
7677
"conditions": {
7778
"BABEL_8_BREAKING": [

packages/babel-core/test/config-chain.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import os from "os";
33
import path from "path";
44
import { fileURLToPath } from "url";
55
import babel from "../lib/index.js";
6+
import rimraf from "rimraf";
67

78
import _getTargets from "@babel/helper-compilation-targets";
89
const getTargets = _getTargets.default;
@@ -68,14 +69,24 @@ function escapeRegExp(string) {
6869
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
6970
}
7071

72+
const tempDirs = [];
73+
7174
async function getTemp(name) {
72-
const cwd = await pfs.mkdtemp(os.tmpdir() + path.sep + name);
75+
const tempDir = os.tmpdir() + path.sep + name;
76+
tempDirs.push(tempDir);
77+
const cwd = await pfs.mkdtemp(tempDir);
7378
const tmp = name => path.join(cwd, name);
7479
const config = name =>
7580
pfs.copyFile(fixture("config-files-templates", name), tmp(name));
7681
return { cwd, tmp, config };
7782
}
7883

84+
afterAll(() => {
85+
for (const dir of tempDirs) {
86+
rimraf.sync(dir);
87+
}
88+
});
89+
7990
describe("buildConfigChain", function () {
8091
describe("test", () => {
8192
describe("single", () => {

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ __metadata:
343343
debug: ^4.1.0
344344
gensync: ^1.0.0-beta.2
345345
json5: ^2.2.1
346+
rimraf: ^3.0.0
346347
semver: "condition:BABEL_8_BREAKING ? ^7.3.4 : ^6.3.0"
347348
languageName: unknown
348349
linkType: soft

0 commit comments

Comments
 (0)