MCPcopy Index your code
hub / github.com/nodejs/node / parseCommandLineWorker

Function parseCommandLineWorker

test/fixtures/snapshot/typescript.js:40536–40611  ·  view source on GitHub ↗
(diagnostics, commandLine, readFile)

Source from the content-addressed store, hash-verified

40534 }
40535 /*@internal*/
40536 function parseCommandLineWorker(diagnostics, commandLine, readFile) {
40537 var options = {};
40538 var watchOptions;
40539 var fileNames = [];
40540 var errors = [];
40541 parseStrings(commandLine);
40542 return {
40543 options: options,
40544 watchOptions: watchOptions,
40545 fileNames: fileNames,
40546 errors: errors
40547 };
40548 function parseStrings(args) {
40549 var i = 0;
40550 while (i < args.length) {
40551 var s = args[i];
40552 i++;
40553 if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) {
40554 parseResponseFile(s.slice(1));
40555 }
40556 else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) {
40557 var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1);
40558 var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true);
40559 if (opt) {
40560 i = parseOptionValue(args, i, diagnostics, opt, options, errors);
40561 }
40562 else {
40563 var watchOpt = getOptionDeclarationFromName(watchOptionsDidYouMeanDiagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true);
40564 if (watchOpt) {
40565 i = parseOptionValue(args, i, watchOptionsDidYouMeanDiagnostics, watchOpt, watchOptions || (watchOptions = {}), errors);
40566 }
40567 else {
40568 errors.push(createUnknownOptionError(inputOptionName, diagnostics, ts.createCompilerDiagnostic, s));
40569 }
40570 }
40571 }
40572 else {
40573 fileNames.push(s);
40574 }
40575 }
40576 }
40577 function parseResponseFile(fileName) {
40578 var text = tryReadFile(fileName, readFile || (function (fileName) { return ts.sys.readFile(fileName); }));
40579 if (!ts.isString(text)) {
40580 errors.push(text);
40581 return;
40582 }
40583 var args = [];
40584 var pos = 0;
40585 while (true) {
40586 while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */)
40587 pos++;
40588 if (pos >= text.length)
40589 break;
40590 var start = pos;
40591 if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) {
40592 pos++;
40593 while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */)

Callers 2

parseCommandLineFunction · 0.85
parseBuildCommandFunction · 0.85

Calls 1

parseStringsFunction · 0.85

Tested by

no test coverage detected