Skip to content

Commit e48038c

Browse files
committed
test(cli): remove orphaned temp dirs in skills loader test
1 parent 54615c5 commit e48038c

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

packages/cli-v3/src/rules/manifest.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { tmpdir } from "node:os";
44
import { join } from "node:path";
55
import { BundledSkillsLoader, loadRulesManifest } from "./manifest.js";
66

7-
async function makeSkillsDir(opts: { withSkill: boolean }): Promise<string> {
7+
async function makeSkillsDir(opts: {
8+
withSkill: boolean;
9+
}): Promise<{ root: string; skillsDir: string }> {
810
const root = await mkdtemp(join(tmpdir(), "bundled-skills-"));
911
const skillsDir = join(root, "skills");
1012
await mkdir(skillsDir, { recursive: true });
@@ -32,19 +34,19 @@ async function makeSkillsDir(opts: { withSkill: boolean }): Promise<string> {
3234
);
3335
}
3436

35-
return skillsDir;
37+
return { root, skillsDir };
3638
}
3739

3840
describe("BundledSkillsLoader", () => {
39-
const dirs: string[] = [];
41+
const roots: string[] = [];
4042

4143
afterAll(async () => {
42-
await Promise.all(dirs.map((d) => rm(d, { recursive: true, force: true })));
44+
await Promise.all(roots.map((d) => rm(d, { recursive: true, force: true })));
4345
});
4446

4547
it("synthesizes a manifest at the given version and stamps it into contents", async () => {
46-
const skillsDir = await makeSkillsDir({ withSkill: true });
47-
dirs.push(skillsDir);
48+
const { root, skillsDir } = await makeSkillsDir({ withSkill: true });
49+
roots.push(root);
4850

4951
const loader = new BundledSkillsLoader(skillsDir, "9.9.9-test.1");
5052
const manifest = await loadRulesManifest(loader);
@@ -65,8 +67,8 @@ describe("BundledSkillsLoader", () => {
6567
});
6668

6769
it("throws when the skills dir has no skills (caller treats as 'nothing to install')", async () => {
68-
const skillsDir = await makeSkillsDir({ withSkill: false });
69-
dirs.push(skillsDir);
70+
const { root, skillsDir } = await makeSkillsDir({ withSkill: false });
71+
roots.push(root);
7072

7173
const loader = new BundledSkillsLoader(skillsDir, "9.9.9-test.1");
7274

0 commit comments

Comments
 (0)