MCPcopy Create free account
hub / github.com/angular/dev-infra / argStringToArray

Function argStringToArray

github-actions/saucelabs/set-saucelabs-env.js:20387–20430  ·  view source on GitHub ↗
(argString)

Source from the content-addressed store, hash-verified

20385 }
20386 };
20387 function argStringToArray(argString) {
20388 const args = [];
20389 let inQuotes = false;
20390 let escaped = false;
20391 let arg = "";
20392 function append(c) {
20393 if (escaped && c !== '"') {
20394 arg += "\\";
20395 }
20396 arg += c;
20397 escaped = false;
20398 }
20399 for (let i = 0; i < argString.length; i++) {
20400 const c = argString.charAt(i);
20401 if (c === '"') {
20402 if (!escaped) {
20403 inQuotes = !inQuotes;
20404 } else {
20405 append(c);
20406 }
20407 continue;
20408 }
20409 if (c === "\\" && escaped) {
20410 append(c);
20411 continue;
20412 }
20413 if (c === "\\" && inQuotes) {
20414 escaped = true;
20415 continue;
20416 }
20417 if (c === " " && !inQuotes) {
20418 if (arg.length > 0) {
20419 args.push(arg);
20420 arg = "";
20421 }
20422 continue;
20423 }
20424 append(c);
20425 }
20426 if (arg.length > 0) {
20427 args.push(arg.trim());
20428 }
20429 return args;
20430 }
20431 var ExecState = class _ExecState extends events.EventEmitter {
20432 constructor(options, toolPath) {
20433 super();

Callers 1

execFunction · 0.70

Calls 2

appendFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected