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

Function parseInteractiveArgs

lib/internal/debugger/inspect.js:225–267  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

223}
224
225function parseInteractiveArgs(args) {
226 const target = ArrayPrototypeShift(args);
227 let host = '127.0.0.1';
228 let port = 9229;
229 let isRemote = false;
230 let script = target;
231 let scriptArgs = args;
232
233 const hostMatch = RegExpPrototypeExec(/^([^:]+):(\d+)$/, target);
234 const portMatch = RegExpPrototypeExec(/^--port=(\d+)$/, target);
235
236 if (hostMatch) {
237 // Connecting to remote debugger
238 host = hostMatch[1];
239 port = Number(hostMatch[2]);
240 isRemote = true;
241 script = null;
242 } else if (portMatch) {
243 // Start on custom port
244 port = Number(portMatch[1]);
245 script = args[0];
246 scriptArgs = ArrayPrototypeSlice(args, 1);
247 } else if (args.length === 1 && RegExpPrototypeExec(/^\d+$/, args[0]) !== null &&
248 target === '-p') {
249 // Start debugger against a given pid
250 const pid = Number(args[0]);
251 try {
252 process._debugProcess(pid);
253 } catch (e) {
254 if (e.code === 'ESRCH') {
255 process.stderr.write(`Target process: ${pid} doesn't exist.\n`);
256 process.exit(kGenericUserError);
257 }
258 throw e;
259 }
260 script = null;
261 isRemote = true;
262 }
263
264 return {
265 host, port, isRemote, script, scriptArgs,
266 };
267}
268
269const kInspectArgOptions = {
270 '__proto__': null,

Callers 1

startInspectFunction · 0.85

Calls 2

writeMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…