未验证 提交 f3b8f4f7 编写于 作者: A Alex Dima

Do not use `process.env` directly in `findExecutable`

上级 56d87a3c
......@@ -204,7 +204,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
// TODO: When conpty is enabled, only enable it when accessibilityMode is off
const enableConpty = false; //terminalConfig.get('windowsEnableConpty') as boolean;
const terminalProcess = new TerminalProcess(shellLaunchConfig, initialCwd, cols, rows, env, enableConpty, this._logService);
const terminalProcess = new TerminalProcess(shellLaunchConfig, initialCwd, cols, rows, env, process.env as platform.IProcessEnvironment, enableConpty, this._logService);
this._setupExtHostProcessListeners(id, terminalProcess);
const error = await terminalProcess.start();
if (error) {
......
......@@ -75,7 +75,7 @@ export class TerminalInstanceService implements ITerminalInstanceService {
}
public createTerminalProcess(shellLaunchConfig: IShellLaunchConfig, cwd: string, cols: number, rows: number, env: IProcessEnvironment, windowsEnableConpty: boolean): ITerminalChildProcess {
return this._instantiationService.createInstance(TerminalProcess, shellLaunchConfig, cwd, cols, rows, env, windowsEnableConpty);
return this._instantiationService.createInstance(TerminalProcess, shellLaunchConfig, cwd, cols, rows, env, process.env as IProcessEnvironment, windowsEnableConpty);
}
private _isWorkspaceShellAllowed(): boolean {
......
......@@ -79,7 +79,7 @@ export async function getMainProcessParentEnv(baseEnvironment: IProcessEnvironme
return mainProcessParentEnv!;
}
export async function findExecutable(command: string, cwd?: string, paths?: string[]): Promise<string | undefined> {
export async function findExecutable(command: string, cwd?: string, paths?: string[], env: IProcessEnvironment = process.env as IProcessEnvironment): Promise<string | undefined> {
// If we have an absolute path then we take it.
if (path.isAbsolute(command)) {
return await exists(command) ? command : undefined;
......@@ -94,8 +94,8 @@ export async function findExecutable(command: string, cwd?: string, paths?: stri
const fullPath = path.join(cwd, command);
return await exists(fullPath) ? fullPath : undefined;
}
if (paths === undefined && isString(process.env.PATH)) {
paths = process.env.PATH.split(path.delimiter);
if (paths === undefined && isString(env.PATH)) {
paths = env.PATH.split(path.delimiter);
}
// No PATH environment. Make path absolute to the cwd.
if (paths === undefined || paths.length === 0) {
......
......@@ -57,6 +57,10 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
cols: number,
rows: number,
env: platform.IProcessEnvironment,
/**
* environment used for `findExecutable`
*/
private readonly _executableEnv: platform.IProcessEnvironment,
windowsEnableConpty: boolean,
@ILogService private readonly _logService: ILogService
) {
......@@ -139,7 +143,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
// The executable isn't an absolute path, try find it on the PATH or CWD
let cwd = slc.cwd instanceof URI ? slc.cwd.path : slc.cwd!;
const envPaths: string[] | undefined = (slc.env && slc.env.PATH) ? slc.env.PATH.split(path.delimiter) : undefined;
const executable = await findExecutable(slc.executable!, cwd, envPaths);
const executable = await findExecutable(slc.executable!, cwd, envPaths, this._executableEnv);
if (!executable) {
return { message: localize('launchFail.executableDoesNotExist', "Path to shell executable \"{0}\" does not exist", slc.executable) };
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册