Skip to content

Commit 064fd71

Browse files
WardenGnawgregg-miskelly
authored andcommitted
Simplifying remoteProcessPicker (#1123)
* Renaming LaunchConfigurations To LaunchBrowserPlatformOptions. * Simplifying retrieving pipeTransport for attach The launch.json configuration is passed in via the args parameter. There is no need to read the launch.json file and find the correct configuration. The old method would only grab the first launch json name that matched. This change allows duplicate launch names but still grabs the correct pipeTransport. * Removing dead code
1 parent f62e38e commit 064fd71

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

src/features/processPicker.ts

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -61,43 +61,20 @@ export class RemoteAttachPicker {
6161
return Promise.reject<string>(new Error("Name not defined in current configuration."));
6262
}
6363

64-
// Build path for launch.json to find pipeTransport
65-
const vscodeFolder: string = path.join(vscode.workspace.rootPath, '.vscode');
66-
let launchJsonPath: string = path.join(vscodeFolder, 'launch.json');
67-
68-
// Read launch.json
69-
let json: any = JSON.parse(fs.readFileSync(launchJsonPath).toString());
70-
71-
// Find correct pipeTransport via selected name
72-
let config;
73-
let configIdx: number;
74-
for (configIdx = 0; configIdx < json.configurations.length; ++configIdx) {
75-
if (json.configurations[configIdx].name === name) {
76-
config = json.configurations[configIdx];
77-
break;
78-
}
79-
}
80-
81-
if (configIdx == json.configurations.length) {
82-
// Name not found in list of given configurations.
83-
return Promise.reject<string>(new Error(name + " could not be found in configurations."));
84-
}
85-
86-
if (!config.pipeTransport || !config.pipeTransport.debuggerPath) {
64+
if (!args.pipeTransport || !args.pipeTransport.debuggerPath) {
8765
// Missing PipeTransport and debuggerPath, prompt if user wanted to just do local attach.
8866
return Promise.reject<string>(new Error("Configuration \"" + name + "\" in launch.json does not have a " +
8967
"pipeTransport argument with debuggerPath for pickRemoteProcess. Use pickProcess for local attach."));
9068
} else {
91-
let pipeProgram = config.pipeTransport.pipeProgram;
92-
let pipeArgs = config.pipeTransport.pipeArgs;
93-
let platformSpecificPipeTransportOptions = RemoteAttachPicker.getPlatformSpecificPipeTransportOptions(config);
69+
let pipeProgram = args.pipeTransport.pipeProgram;
70+
let pipeArgs = args.pipeTransport.pipeArgs;
71+
let platformSpecificPipeTransportOptions = RemoteAttachPicker.getPlatformSpecificPipeTransportOptions(args);
9472

9573
if (platformSpecificPipeTransportOptions) {
9674
pipeProgram = platformSpecificPipeTransportOptions.pipeProgram || pipeProgram;
9775
pipeArgs = platformSpecificPipeTransportOptions.pipeArgs || pipeArgs;
9876
}
9977

100-
10178
let argList = RemoteAttachPicker.createArgumentList(pipeArgs);
10279
let pipeCmd: string = `"${pipeProgram}" ${argList}`;
10380
return RemoteAttachPicker.getRemoteOSAndProcesses(pipeCmd).then(processes => {
@@ -170,14 +147,6 @@ export class RemoteAttachPicker {
170147
}
171148
});
172149
}
173-
174-
public static getRemoteProcesses(pipeCmd: string, os: string): Promise<AttachItem[]> {
175-
const psCommand = os === 'darwin' ? RemoteAttachPicker.osxPsCommand : RemoteAttachPicker.linuxPsCommand;
176-
177-
return execChildProcessAndOutputErrorToChannel(`${pipeCmd} ${psCommand}`, null, RemoteAttachPicker._channel).then(output => {
178-
return sortProcessEntries(PsOutputParser.parseProcessFromPs(output), os);
179-
});
180-
}
181150
}
182151

183152
class Process {

0 commit comments

Comments
 (0)