|
| 1 | +import fs from "node:fs"; |
1 | 2 | import path from "node:path"; |
2 | 3 | import { describe, expect, it } from "vitest"; |
3 | 4 | import { loadOpenClawPlugins } from "./loader.js"; |
4 | 5 | |
5 | 6 | describe("source checkout bundled plugin runtime", () => { |
6 | | -it("loads enabled bundled plugins from built dist when available", () => { |
| 7 | +it("loads enabled bundled plugins from built dist or source checkout", () => { |
7 | 8 | const registry = loadOpenClawPlugins({ |
8 | 9 | cache: false, |
9 | 10 | onlyPluginIds: ["twitch"], |
@@ -21,9 +22,16 @@ describe("source checkout bundled plugin runtime", () => {
|
21 | 22 | status: "loaded", |
22 | 23 | origin: "bundled", |
23 | 24 | }); |
24 | | -expect(twitch?.source).toContain( |
25 | | -`${path.sep}dist${path.sep}extensions${path.sep}twitch${path.sep}index.js`, |
26 | | -); |
27 | | -expect(twitch?.rootDir).toContain(`${path.sep}dist${path.sep}extensions${path.sep}twitch`); |
| 25 | + |
| 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`; |
| 33 | + |
| 34 | +expect(twitch?.source).toContain(expectedRuntime); |
| 35 | +expect(twitch?.rootDir).toContain(expectedRoot); |
28 | 36 | }); |
29 | 37 | }); |