|
1 | | -import fs from "node:fs"; |
2 | 1 | import path from "node:path"; |
3 | 2 | import { describe, expect, it } from "vitest"; |
4 | 3 | import { loadOpenClawPlugins } from "./loader.js"; |
@@ -23,15 +22,18 @@ describe("source checkout bundled plugin runtime", () => {
|
23 | 22 | origin: "bundled", |
24 | 23 | }); |
25 | 24 | |
26 | | -const builtRuntime = path.join(process.cwd(), "dist", "extensions", "twitch", "index.js"); |
27 | | -const expectedRuntime = fs.existsSync(builtRuntime) |
28 | | - ? `${path.sep}dist${path.sep}extensions${path.sep}twitch${path.sep}index.js` |
29 | | - : `${path.sep}extensions${path.sep}twitch${path.sep}index.ts`; |
30 | | -const expectedRoot = fs.existsSync(builtRuntime) |
31 | | - ? `${path.sep}dist${path.sep}extensions${path.sep}twitch` |
32 | | - : `${path.sep}extensions${path.sep}twitch`; |
| 25 | +const runtimeCandidates = [ |
| 26 | +`${path.sep}dist${path.sep}extensions${path.sep}twitch${path.sep}index.js`, |
| 27 | +`${path.sep}extensions${path.sep}twitch${path.sep}index.ts`, |
| 28 | +]; |
| 29 | +const rootCandidates = [ |
| 30 | +`${path.sep}dist${path.sep}extensions${path.sep}twitch`, |
| 31 | +`${path.sep}extensions${path.sep}twitch`, |
| 32 | +]; |
| 33 | +const includesAny = (actual: string | undefined, candidates: readonly string[]) => |
| 34 | +actual !== undefined && candidates.some((candidate) => actual.includes(candidate)); |
33 | 35 | |
34 | | -expect(twitch?.source).toContain(expectedRuntime); |
35 | | -expect(twitch?.rootDir).toContain(expectedRoot); |
| 36 | +expect(includesAny(twitch?.source, runtimeCandidates)).toBe(true); |
| 37 | +expect(includesAny(twitch?.rootDir, rootCandidates)).toBe(true); |
36 | 38 | }); |
37 | 39 | }); |