34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { isCompiledBinary, resolveAppRoot, resolveDefaultLauncher } from "./runtime.js";
|
|
|
|
describe("runtime detection and launcher", () => {
|
|
test("isCompiledBinary detects bun runtime executable vs standalone binary", () => {
|
|
expect(isCompiledBinary("/Users/user/.bun/bin/bun", "file:///Users/user/code/src/cli.ts")).toBe(false);
|
|
expect(isCompiledBinary("C:\\Users\\user\\.bun\\bin\\bun.exe", "file:///C:/code/src/cli.ts")).toBe(false);
|
|
expect(isCompiledBinary("/usr/local/bin/seal-home", "file:///Users/user/code/src/cli.ts")).toBe(true);
|
|
expect(isCompiledBinary("/Users/user/.bun/bin/bun", "file:///$bunfs/root/src/cli.ts")).toBe(true);
|
|
});
|
|
|
|
test("resolveAppRoot returns cwd for compiled binary and project root for source", () => {
|
|
const sourceRoot = resolveAppRoot("/Users/user/code/src/cli.ts", false);
|
|
expect(sourceRoot).toBe("/Users/user/code");
|
|
|
|
const binaryRoot = resolveAppRoot(undefined, true);
|
|
expect(binaryRoot).toBe(process.cwd());
|
|
});
|
|
|
|
test("resolveDefaultLauncher configures args based on compiled mode", () => {
|
|
const sourceLauncher = resolveDefaultLauncher("/Users/user/code/src/cli.ts", false, "/path/to/bun");
|
|
expect(sourceLauncher).toEqual({
|
|
command: "/path/to/bun",
|
|
args: ["/Users/user/code/src/cli.ts"]
|
|
});
|
|
|
|
const binaryLauncher = resolveDefaultLauncher("/ignored", true, "/usr/local/bin/seal-home");
|
|
expect(binaryLauncher).toEqual({
|
|
command: "/usr/local/bin/seal-home",
|
|
args: []
|
|
});
|
|
});
|
|
});
|