mirror of
https://github.com/hypit-ai/hypit.git
synced 2026-11-18 20:20:34 +00:00
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { realpath } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
|
|
import type { CliDistribution } from "../../src/distribution.js";
|
|
import { runCliApplication } from "../../src/application.js";
|
|
import type { CliIo } from "../../src/output.js";
|
|
import { createLocalRuntimeCliCommandModules } from "@hypit/runtime-local/cli";
|
|
import type { LocalRuntimeHost } from "@hypit/runtime-local";
|
|
|
|
export const applicationCwd = tmpdir();
|
|
|
|
export const runCli = async (argv: readonly string[], output: CliIo, selected: CliDistribution) => await runCliApplication(
|
|
argv,
|
|
output,
|
|
{
|
|
// The real video application assembles both generic and Local Runtime Host
|
|
// ports. These focused doubles do the same when mounting Local commands.
|
|
distribution: selected,
|
|
commandModules: createLocalRuntimeCliCommandModules({
|
|
...(selected.packageRoot === undefined ? {} : { packageRoot: selected.packageRoot }),
|
|
openLocalRuntimeHost: async (path, options) =>
|
|
await selected.openRuntimeHost(path, options) as LocalRuntimeHost,
|
|
}),
|
|
cwd: applicationCwd,
|
|
resolveProjectRoot: async (explicit) => await realpath(explicit ?? tmpdir()),
|
|
},
|
|
);
|