MCPcopy Create free account
hub / github.com/microsoft/vscode-js-debug / resolveProcessId

Function resolveProcessId

src/ui/processPicker.ts:61–88  ·  view source on GitHub ↗
(
  fsUtils: LocalFsUtils,
  config: ResolvingNodeAttachConfiguration,
  setCwd = false,
)

Source from the content-addressed store, hash-verified

59 * if it was cancelled.
60 */
61export async function resolveProcessId(
62 fsUtils: LocalFsUtils,
63 config: ResolvingNodeAttachConfiguration,
64 setCwd = false,
65) {
66 // we resolve Process Picker early (before VS Code) so that we can probe the process for its protocol
67 const processId = config.processId?.trim();
68 const result = processId && decodePidAndPort(processId);
69 if (!result || isNaN(result.pid)) {
70 throw new Error(
71 l10n.t("Attach to process: '{0}' doesn't look like a process id.", processId || '<unknown>'),
72 );
73 }
74
75 if (!result.port) {
76 putPidInDebugMode(result.pid);
77 }
78
79 config.port = result.port || INSPECTOR_PORT_DEFAULT;
80 delete config.processId;
81
82 if (setCwd) {
83 const inferredWd = await inferWorkingDirectory(fsUtils, result.pid);
84 if (inferredWd) {
85 config.cwd = inferredWd;
86 }
87 }
88}
89
90async function inferWorkingDirectory(fsUtils: LocalFsUtils, processId?: number) {
91 const inferredWd = processId && (await processTree.getWorkingDirectory(processId));

Calls 3

decodePidAndPortFunction · 0.85
putPidInDebugModeFunction · 0.85
inferWorkingDirectoryFunction · 0.85

Tested by

no test coverage detected