Files
openclaw/src/index.test.ts
Ayaan Zaidi d978ace90b fix: isolate CLI startup imports (#50212)
* fix: isolate CLI startup imports

* fix: clarify CLI preflight behavior

* fix: tighten main-module detection

* fix: isolate CLI startup imports (#50212)
2026-03-19 10:34:29 +05:30

28 lines
822 B
TypeScript

import fs from "node:fs";
import { afterEach, describe, expect, it, vi } from "vitest";
describe("legacy root entry", () => {
afterEach(() => {
vi.resetModules();
});
it("routes the package root export to the pure library entry", () => {
const packageJson = JSON.parse(
fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"),
) as {
exports?: Record<string, unknown>;
main?: string;
};
expect(packageJson.main).toBe("dist/index.js");
expect(packageJson.exports?.["."]).toBe("./dist/index.js");
});
it("does not run CLI bootstrap when imported as a library dependency", async () => {
const mod = await import("./index.js");
expect(typeof mod.applyTemplate).toBe("function");
expect(typeof mod.runLegacyCliEntry).toBe("function");
});
});