INNER CODE UNIT · TypeScript
onlyIndex
rit3zh/reacticx · cloudflare/codebase/index.ts:71
const onlyIndex = argv.findIndex((arg) => arg === "--only" || arg.startsWith("--only="));
let only: SourceId[] = [];
if (onlyIndex !== -1) {
const raw = argv[onlyIndex]!.includes("=")
? argv[onlyIndex]!.split("=")[1]
: argv[onlyIndex + 1];
const requested = (raw ?? "").split(",").map((part) => part.trim()).filter(Boolean);
const unknown = requested.filter((id) => !sourceIds.includes(id as SourceId));
if (requested.length === 0) throw new Error(`--only needs a value: ${sourceIds.join(", ")}`);
if (unknown.length > 0) {
throw new Error(`unknown source ${unknown.join(", ")} — expected ${sourceIds.join(", ")}`);
}
only = requested as SourceId[];
}