Files
openclaw/scripts/e2e/lib/codex-media-path/limits.mjs
2026-05-29 00:46:22 +02:00

12 lines
361 B
JavaScript

export function readPositiveIntEnv(name, fallback, env = process.env) {
const text = String(env[name] ?? fallback).trim();
if (!/^\d+$/u.test(text)) {
throw new Error(`invalid ${name}: ${text}`);
}
const value = Number(text);
if (!Number.isSafeInteger(value) || value <= 0) {
throw new Error(`invalid ${name}: ${text}`);
}
return value;
}