mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
// Typed bridge to the plain-Node Windows command helpers.
|
|
const runtimeSpecifier = "../windows-cmd-helpers.mjs";
|
|
const runtime: unknown = await import(runtimeSpecifier);
|
|
|
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
}
|
|
|
|
function runtimeFunction(name: string): (...args: unknown[]) => unknown {
|
|
if (!isRecord(runtime) || !(name in runtime)) {
|
|
throw new Error(`windows command helper is missing ${name}`);
|
|
}
|
|
const value = runtime[name];
|
|
if (typeof value !== "function") {
|
|
throw new Error(`windows command helper ${name} is not callable`);
|
|
}
|
|
return (...args) => value(...args);
|
|
}
|
|
|
|
const buildCmdExeCommandLineImpl = runtimeFunction("buildCmdExeCommandLine");
|
|
const resolvePathEnvKeyImpl = runtimeFunction("resolvePathEnvKey");
|
|
const resolveWindowsCmdExePathImpl = runtimeFunction("resolveWindowsCmdExePath");
|
|
|
|
export function buildCmdExeCommandLine(command: string, args: string[]): string {
|
|
const result = buildCmdExeCommandLineImpl(command, args);
|
|
if (typeof result !== "string") {
|
|
throw new Error("buildCmdExeCommandLine returned a non-string result");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function resolvePathEnvKey(env: NodeJS.ProcessEnv): string {
|
|
const result = resolvePathEnvKeyImpl(env);
|
|
if (typeof result !== "string") {
|
|
throw new Error("resolvePathEnvKey returned a non-string result");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function resolveWindowsCmdExePath(env: NodeJS.ProcessEnv = process.env): string {
|
|
const result = resolveWindowsCmdExePathImpl(env);
|
|
if (typeof result !== "string") {
|
|
throw new Error("resolveWindowsCmdExePath returned a non-string result");
|
|
}
|
|
return result;
|
|
}
|