@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
ts 40 lines 1.34 KB
Raw
1 import { assert, describe, it } from "@effect/vitest";
2 import * as ConfigProvider from "effect/ConfigProvider";
3 import * as Effect from "effect/Effect";
4 import * as Layer from "effect/Layer";
5 import * as HostProcess from "@t3tools/shared/HostProcess";
6
7 import { getDefaultBuildArch } from "./build-target-arch.ts";
8
9 const compactEnv = (env: Readonly<Record<string, string | undefined>>): Record<string, string> =>
10 Object.fromEntries(
11 Object.entries(env).filter((entry): entry is [string, string] => entry[1] !== undefined),
12 );
13
14 const withHostRuntime = (
15 platform: NodeJS.Platform,
16 arch: NodeJS.Architecture,
17 env: Readonly<Record<string, string | undefined>> = {},
18 ) =>
19 Effect.provide(
20 Layer.mergeAll(
21 Layer.succeed(HostProcess.Platform, platform),
22 Layer.succeed(HostProcess.Architecture, arch),
23 ConfigProvider.layer(ConfigProvider.fromEnv({ env: compactEnv(env) })),
24 ),
25 );
26
27 describe("build-target-arch", () => {
28 it.effect("uses the resolved host arch when selecting the default Windows build arch", () =>
29 Effect.gen(function* () {
30 const arch = yield* getDefaultBuildArch("win", { archChoices: ["x64", "arm64"] }).pipe(
31 withHostRuntime("win32", "x64", {
32 PROCESSOR_ARCHITECTURE: "AMD64",
33 PROCESSOR_ARCHITEW6432: "ARM64",
34 }),
35 );
36
37 assert.equal(arch, "arm64");
38 }),
39 );
40 });