mirror of
https://github.com/hanzoai/dev-desktop.git
synced 2026-11-20 01:07:23 +00:00
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { assert, describe, it } from "@effect/vitest";
|
|
import * as ConfigProvider from "effect/ConfigProvider";
|
|
import * as Effect from "effect/Effect";
|
|
import * as Layer from "effect/Layer";
|
|
import * as HostProcess from "@hanzodev/shared/HostProcess";
|
|
|
|
import { getDefaultBuildArch } from "./build-target-arch.ts";
|
|
|
|
const compactEnv = (env: Readonly<Record<string, string | undefined>>): Record<string, string> =>
|
|
Object.fromEntries(
|
|
Object.entries(env).filter((entry): entry is [string, string] => entry[1] !== undefined),
|
|
);
|
|
|
|
const withHostRuntime = (
|
|
platform: NodeJS.Platform,
|
|
arch: NodeJS.Architecture,
|
|
env: Readonly<Record<string, string | undefined>> = {},
|
|
) =>
|
|
Effect.provide(
|
|
Layer.mergeAll(
|
|
Layer.succeed(HostProcess.Platform, platform),
|
|
Layer.succeed(HostProcess.Architecture, arch),
|
|
ConfigProvider.layer(ConfigProvider.fromEnv({ env: compactEnv(env) })),
|
|
),
|
|
);
|
|
|
|
describe("build-target-arch", () => {
|
|
it.effect("uses the resolved host arch when selecting the default Windows build arch", () =>
|
|
Effect.gen(function* () {
|
|
const arch = yield* getDefaultBuildArch("win", { archChoices: ["x64", "arm64"] }).pipe(
|
|
withHostRuntime("win32", "x64", {
|
|
PROCESSOR_ARCHITECTURE: "AMD64",
|
|
PROCESSOR_ARCHITEW6432: "ARM64",
|
|
}),
|
|
);
|
|
|
|
assert.equal(arch, "arm64");
|
|
}),
|
|
);
|
|
});
|