MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / parseArgs

Function parseArgs

scripts/build-harmony-har.js:272–302  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

270}
271
272function parseArgs(argv) {
273 const parsed = {};
274
275 for (let index = 0; index < argv.length; index += 1) {
276 const token = argv[index];
277 if (!token.startsWith('--')) {
278 fail(`Unsupported argument: ${token}`);
279 }
280
281 const keyValue = token.slice(2).split('=');
282 const key = keyValue[0];
283 const inlineValue = keyValue.length > 1 ? keyValue.slice(1).join('=') : '';
284
285 if (key === 'skip-install') {
286 parsed[key] = true;
287 continue;
288 }
289
290 const value = inlineValue || argv[index + 1];
291 if (!value || value.startsWith('--')) {
292 fail(`Missing value for --${key}`);
293 }
294
295 parsed[key] = value;
296 if (!inlineValue) {
297 index += 1;
298 }
299 }
300
301 return parsed;
302}
303
304function normalizeBuildMode(value) {
305 const mode = String(value).toLowerCase();

Callers 1

Calls 1

failFunction · 0.85

Tested by

no test coverage detected