Skip to content

Commit 3bf42ac

Browse files
committed
invert target/profile check in cleanup
closes #356
1 parent 6e5b278 commit 3bf42ac

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎src/cleanup.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ export async function cleanTargetDir(targetDir: string, packages: Packages, chec
1515
for await (const dirent of dir) {
1616
if (dirent.isDirectory()) {
1717
let dirName = path.join(dir.path, dirent.name);
18-
// is it a profile dir, or a nested target dir?
19-
let isNestedTarget =
20-
(await exists(path.join(dirName, "CACHEDIR.TAG"))) || (await exists(path.join(dirName, ".rustc_info.json")));
18+
// Target-triple directories do not contain Cargo's target directory
19+
// markers, so identify profiles by their artifact directories as well.
20+
const isProfile =
21+
dirent.name === "tests" ||
22+
(await exists(path.join(dirName, "build"))) ||
23+
(await exists(path.join(dirName, ".fingerprint"))) ||
24+
(await exists(path.join(dirName, "deps")));
2125

2226
try {
23-
if (isNestedTarget) {
24-
await cleanTargetDir(dirName, packages, checkTimestamp);
25-
} else {
27+
if (isProfile) {
2628
await cleanProfileTarget(dirName, packages, checkTimestamp);
29+
} else {
30+
await cleanTargetDir(dirName, packages, checkTimestamp);
2731
}
2832
} catch {}
2933
} else if (dirent.name !== "CACHEDIR.TAG") {

0 commit comments

Comments
 (0)