diff --git a/test/plugin-clawhub-release.test.ts b/test/plugin-clawhub-release.test.ts index 267d26dd147..0903c296657 100644 --- a/test/plugin-clawhub-release.test.ts +++ b/test/plugin-clawhub-release.test.ts @@ -1,6 +1,5 @@ import { execFileSync } from "node:child_process"; -import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; -import { tmpdir } from "node:os"; +import { mkdirSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { afterEach, describe, expect, it } from "vitest"; import { @@ -12,16 +11,12 @@ import { resolveSelectedClawHubPublishablePluginPackages, type PublishablePluginPackage, } from "../scripts/lib/plugin-clawhub-release.ts"; +import { cleanupTempDirs, makeTempRepoRoot } from "./helpers/temp-repo.js"; const tempDirs: string[] = []; afterEach(() => { - while (tempDirs.length > 0) { - const dir = tempDirs.pop(); - if (dir) { - rmSync(dir, { recursive: true, force: true }); - } - } + cleanupTempDirs(tempDirs); }); describe("resolveChangedClawHubPublishablePluginPackages", () => { @@ -294,8 +289,7 @@ function createTempPluginRepo( includeClawHubContract?: boolean; } = {}, ) { - const repoDir = mkdtempSync(join(tmpdir(), "openclaw-clawhub-release-")); - tempDirs.push(repoDir); + const repoDir = makeTempRepoRoot(tempDirs, "openclaw-clawhub-release-"); const extensionId = options.extensionId ?? "demo-plugin"; const extensionIds = [extensionId, ...(options.extraExtensionIds ?? [])];