(args: string[])
| 245 | |
| 246 | // fallow-ignore-next-line complexity |
| 247 | export 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 | } |
no test coverage detected