MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseArgs

Function parseArgs

packages/aws-lambda/scripts/build-zip.ts:83–107  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

81};
82
83function parseArgs(argv: string[]): BuildOptions {
84 const opts = { ...DEFAULT_OPTIONS };
85 for (const arg of argv.slice(2)) {
86 if (arg.startsWith("--source=")) {
87 const v = arg.slice("--source=".length);
88 if (v !== "sparticuz" && v !== "chrome-headless-shell") {
89 throw new Error(`--source must be 'sparticuz' or 'chrome-headless-shell' (got ${v})`);
90 }
91 opts.source = v;
92 } else if (arg.startsWith("--max-unzipped=")) {
93 opts.maxUnzippedBytes = Number.parseInt(arg.slice("--max-unzipped=".length), 10);
94 } else if (arg.startsWith("--max-zipped=")) {
95 opts.maxZippedBytes = Number.parseInt(arg.slice("--max-zipped=".length), 10);
96 } else if (arg === "--help") {
97 console.log(
98 "Usage: tsx build-zip.ts [--source=sparticuz|chrome-headless-shell]\n" +
99 " [--max-unzipped=<bytes>] [--max-zipped=<bytes>]",
100 );
101 process.exit(0);
102 } else {
103 throw new Error(`Unknown flag: ${arg}`);
104 }
105 }
106 return opts;
107}
108
109async function main(): Promise<void> {
110 const opts = parseArgs(process.argv);

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected