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

Function resolveProcessId

valdi/vscode_debugger/src/ui/processPicker.ts:60–87  ·  view source on GitHub ↗
(config: ResolvingNodeAttachConfiguration, setCwd = false)

Source from the content-addressed store, hash-verified

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

Calls 4

decodePidAndPortFunction · 0.85
putPidInDebugModeFunction · 0.85
inferWorkingDirectoryFunction · 0.85
trimMethod · 0.45

Tested by

no test coverage detected