git: isolate ipc env

This commit is contained in:
Joao Moreno
2019-11-20 16:06:55 +01:00
parent af864aed2f
commit f37b9d742c
5 changed files with 22 additions and 12 deletions

View File

@@ -7,7 +7,17 @@ import * as http from 'http';
export class IPCClient {
constructor(private handlerName: string, private ipcHandlePath: string) { }
private ipcHandlePath: string;
constructor(private handlerName: string) {
const ipcHandlePath = process.env['VSCODE_GIT_IPC_HANDLE'];
if (!ipcHandlePath) {
throw new Error('Missing VSCODE_GIT_IPC_HANDLE');
}
this.ipcHandlePath = ipcHandlePath;
}
call(request: any): Promise<any> {
const opts: http.RequestOptions = {

View File

@@ -48,6 +48,7 @@ export async function createIPCServer(): Promise<IIPCServer> {
export interface IIPCServer extends Disposable {
readonly ipcHandlePath: string | undefined;
getEnv(): any;
registerHandler(name: string, handler: IIPCHandler): Disposable;
}
@@ -92,6 +93,10 @@ class IPCServer implements IIPCServer, Disposable {
});
}
getEnv(): any {
return { VSCODE_GIT_IPC_HANDLE: this.ipcHandlePath };
}
dispose(): void {
this.handlers.clear();
this.server.close();