MCPcopy Index your code
hub / github.com/callstack/agent-device / parseReplayRuntimeFlags

Function parseReplayRuntimeFlags

src/replay/script-utils.ts:247–304  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

245
246// fallow-ignore-next-line complexity
247export function parseReplayRuntimeFlags(args: string[]): {
248 positionals: string[];
249 flags: {
250 platform?: 'ios' | 'android';
251 metroHost?: string;
252 metroPort?: number;
253 bundleUrl?: string;
254 launchUrl?: string;
255 };
256} {
257 const positionals: string[] = [];
258 const flags: {
259 platform?: 'ios' | 'android';
260 metroHost?: string;
261 metroPort?: number;
262 bundleUrl?: string;
263 launchUrl?: string;
264 } = {};
265
266 for (let index = 0; index < args.length; index += 1) {
267 const token = args[index]!;
268 const nextArg = args[index + 1];
269 if (token === '--platform' && nextArg !== undefined) {
270 const platform = nextArg;
271 if (platform === 'ios' || platform === 'android') {
272 flags.platform = platform;
273 }
274 index += 1;
275 continue;
276 }
277 if (token === '--metro-host' && nextArg !== undefined) {
278 flags.metroHost = nextArg;
279 index += 1;
280 continue;
281 }
282 if (token === '--metro-port' && nextArg !== undefined) {
283 const parsedPort = parseNonNegativeIntToken(nextArg);
284 if (parsedPort !== null) {
285 flags.metroPort = parsedPort;
286 }
287 index += 1;
288 continue;
289 }
290 if (token === '--bundle-url' && nextArg !== undefined) {
291 flags.bundleUrl = nextArg;
292 index += 1;
293 continue;
294 }
295 if (token === '--launch-url' && nextArg !== undefined) {
296 flags.launchUrl = nextArg;
297 index += 1;
298 continue;
299 }
300 positionals.push(token);
301 }
302
303 return { positionals, flags };
304}

Callers 2

parseReplayOpenFlagsFunction · 0.90
parseReplayScriptLineFunction · 0.90

Calls 2

parseNonNegativeIntTokenFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected