forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessFactory.ts
More file actions
27 lines (24 loc) · 1.27 KB
/
processFactory.ts
File metadata and controls
27 lines (24 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { inject, injectable } from 'inversify';
import { Uri } from 'vscode';
import { IDisposableRegistry } from '../types';
import { IEnvironmentVariablesProvider } from '../variables/types';
import { ProcessService } from './proc';
import { IBufferDecoder, IProcessLogger, IProcessService, IProcessServiceFactory } from './types';
@injectable()
export class ProcessServiceFactory implements IProcessServiceFactory {
constructor(
@inject(IEnvironmentVariablesProvider) private readonly envVarsService: IEnvironmentVariablesProvider,
@inject(IProcessLogger) private readonly processLogger: IProcessLogger,
@inject(IBufferDecoder) private readonly decoder: IBufferDecoder,
@inject(IDisposableRegistry) private readonly disposableRegistry: IDisposableRegistry
) {}
public async create(resource?: Uri): Promise<IProcessService> {
const customEnvVars = await this.envVarsService.getEnvironmentVariables(resource);
const proc: IProcessService = new ProcessService(this.decoder, customEnvVars);
this.disposableRegistry.push(proc);
return proc.on('exec', this.processLogger.logProcess.bind(this.processLogger));
}
}