mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 10:41:23 +00:00
refactor: dedupe trim reader aliases
This commit is contained in:
@@ -75,16 +75,16 @@ export function applyExistingCronSchedulePatch(
|
||||
}
|
||||
|
||||
function normalizeScheduleOptions(options: ScheduleOptionInput): NormalizedScheduleOptions {
|
||||
const staggerRaw = readTrimmedString(options.stagger);
|
||||
const staggerRaw = normalizeOptionalString(options.stagger) ?? "";
|
||||
const useExact = Boolean(options.exact);
|
||||
if (staggerRaw && useExact) {
|
||||
throw new Error("Choose either --stagger or --exact, not both");
|
||||
}
|
||||
return {
|
||||
at: readTrimmedString(options.at),
|
||||
every: readTrimmedString(options.every),
|
||||
cronExpr: readTrimmedString(options.cron),
|
||||
tz: readOptionalString(options.tz),
|
||||
at: normalizeOptionalString(options.at) ?? "",
|
||||
every: normalizeOptionalString(options.every) ?? "",
|
||||
cronExpr: normalizeOptionalString(options.cron) ?? "",
|
||||
tz: normalizeOptionalString(options.tz),
|
||||
requestedStaggerMs: parseCronStaggerMs({ staggerRaw, useExact }),
|
||||
};
|
||||
}
|
||||
@@ -125,11 +125,3 @@ function resolveDirectSchedule(options: NormalizedScheduleOptions): CronSchedule
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function readOptionalString(value: unknown): string | undefined {
|
||||
return normalizeOptionalString(value);
|
||||
}
|
||||
|
||||
function readTrimmedString(value: unknown): string {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user