mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 14:21:34 +00:00
* fix(e2e): stabilize cross-version Parallels upgrades * fix(e2e): avoid inline macOS guest probes * fix(e2e): detach Windows dev updates * fix(e2e): detach macOS guest updates with Node * fix(e2e): initialize skipped upgrade config * fix(update): use partial clone for dev checkout * fix(update): keep Windows dev checkouts clean * fix(e2e): pin Parallels dev update targets * fix(e2e): own Parallels gateway restarts * fix(e2e): verify pinned Parallels checkouts * fix(e2e): forward Parallels update budgets * fix(e2e): use canonical provider auth choices * chore: leave changelog to release automation * test(ui): stabilize route waits on loaded runners
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
// Env Limits script supports OpenClaw repository automation.
|
|
import { die } from "./host-command.ts";
|
|
|
|
const positiveIntPattern = /^[1-9]\d*$/u;
|
|
const fullGitCommitPattern = /^[0-9a-f]{40}$/iu;
|
|
|
|
export function parsePositiveInt(value: string, label: string): number {
|
|
const trimmed = value.trim();
|
|
if (!positiveIntPattern.test(trimmed)) {
|
|
die(`invalid ${label}: ${value}`);
|
|
}
|
|
const parsed = Number(trimmed);
|
|
if (!Number.isSafeInteger(parsed)) {
|
|
die(`invalid ${label}: ${value}`);
|
|
}
|
|
return parsed;
|
|
}
|
|
|
|
export function parseTcpPort(value: string, label: string): number {
|
|
const parsed = parsePositiveInt(value, label);
|
|
if (parsed > 65_535) {
|
|
die(`invalid ${label}: ${value}`);
|
|
}
|
|
return parsed;
|
|
}
|
|
|
|
export function readPositiveIntEnv(name: string, fallback: number): number {
|
|
const raw = process.env[name];
|
|
if (raw == null || raw.trim() === "") {
|
|
return fallback;
|
|
}
|
|
return parsePositiveInt(raw, name);
|
|
}
|
|
|
|
export function readGitCommitEnv(name: string): string | undefined {
|
|
const raw = process.env[name];
|
|
if (raw == null || raw.trim() === "") {
|
|
return undefined;
|
|
}
|
|
const value = raw.trim();
|
|
if (!fullGitCommitPattern.test(value)) {
|
|
die(`invalid ${name}: expected a full 40-character commit SHA`);
|
|
}
|
|
return value.toLowerCase();
|
|
}
|