MCPcopy Create free account
hub / github.com/Snapchat/Valdi / analyseArguments

Function analyseArguments

valdi/vscode_debugger/src/ui/processTree/processTree.ts:66–91  ·  view source on GitHub ↗
(args: string)

Source from the content-addressed store, hash-verified

64 * Analyse the given command line arguments and extract debug port and protocol from it.
65 */
66export function analyseArguments(args: string) {
67 const DEBUG_FLAGS_PATTERN = /--inspect(-brk)?(=((\[[0-9a-fA-F:]*\]|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z0-9\.]*):)?(\d+))?/;
68 const DEBUG_PORT_PATTERN = /--inspect-port=(\d+)/;
69
70 let address: string | undefined;
71 let port: number | undefined;
72
73 // match --inspect, --inspect=1234, --inspect-brk, --inspect-brk=1234
74 let matches = DEBUG_FLAGS_PATTERN.exec(args);
75 if (matches && matches.length >= 1) {
76 if (matches.length >= 5 && matches[4]) {
77 address = matches[4];
78 }
79 if (matches.length >= 6 && matches[5]) {
80 port = parseInt(matches[5]);
81 }
82 }
83
84 // a --inspect-port=1234 overrides the port
85 matches = DEBUG_PORT_PATTERN.exec(args);
86 if (matches && matches.length === 2) {
87 port = parseInt(matches[1]);
88 }
89
90 return { address, port };
91}

Callers 3

watchAllChildrenFunction · 0.90
watchAllChildrenFunction · 0.90
listProcessesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected