Skip to content

Commit dddbfa6

Browse files
committed
Remove process.env from tasks
Part of microsoft#108804
1 parent 1f06361 commit dddbfa6

File tree

3 files changed

+8
-61
lines changed

3 files changed

+8
-61
lines changed

src/vs/workbench/api/node/extHostTask.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export class ExtHostTask extends ExtHostTaskBase {
4444
authority: initData.remote.authority,
4545
platform: process.platform
4646
});
47+
} else {
48+
this.registerTaskSystem(Schemas.file, {
49+
scheme: Schemas.file,
50+
authority: '',
51+
platform: process.platform
52+
});
4753
}
4854
this._proxy.$registerSupportedExecutions(true, true, true);
4955
}

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
547547
}
548548

549549
private getTaskSystemInfo(key: string): TaskSystemInfo | undefined {
550-
if (this.environmentService.remoteAuthority) {
551-
return this._taskSystemInfos.get(key);
552-
}
553-
return undefined;
550+
return this._taskSystemInfos.get(key);
554551
}
555552

556553
public extensionCallbackTaskComplete(task: Task, result: number): Promise<void> {

src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
4444
import { Schemas } from 'vs/base/common/network';
4545
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
4646
import { IPathService } from 'vs/workbench/services/path/common/pathService';
47-
import { env as processEnv, cwd as processCwd } from 'vs/base/common/process';
4847
import { IViewsService, IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views';
4948
import { ILogService } from 'vs/platform/log/common/log';
5049
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -540,7 +539,7 @@ export class TerminalTaskSystem implements ITaskSystem {
540539
const paths = envPath ? envPath.split(path.delimiter).map(p => this.configurationResolverService.resolve(workspaceFolder, p)) : undefined;
541540
let foundExecutable = await systemInfo?.findExecutable(command, cwd, paths);
542541
if (!foundExecutable) {
543-
foundExecutable = await this.findExecutable(command, cwd, paths);
542+
foundExecutable = path.join(cwd ?? '', command);
544543
}
545544
return foundExecutable;
546545
}
@@ -1602,59 +1601,4 @@ export class TerminalTaskSystem implements ITaskSystem {
16021601
outputChannel.append(output);
16031602
}
16041603
}
1605-
1606-
private async fileExists(path: string): Promise<boolean> {
1607-
const uri: URI = resources.toLocalResource(URI.from({ scheme: Schemas.file, path: path }), this.environmentService.remoteAuthority, this.pathService.defaultUriScheme);
1608-
if (await this.fileService.exists(uri)) {
1609-
return !((await this.fileService.resolve(uri)).isDirectory);
1610-
}
1611-
return false;
1612-
}
1613-
1614-
private async findExecutable(command: string, cwd?: string, paths?: string[]): Promise<string> {
1615-
// If we have an absolute path then we take it.
1616-
if (path.isAbsolute(command)) {
1617-
return command;
1618-
}
1619-
if (cwd === undefined) {
1620-
cwd = processCwd();
1621-
}
1622-
const dir = path.dirname(command);
1623-
if (dir !== '.') {
1624-
// We have a directory and the directory is relative (see above). Make the path absolute
1625-
// to the current working directory.
1626-
return path.join(cwd, command);
1627-
}
1628-
if (paths === undefined && Types.isString(processEnv.PATH)) {
1629-
paths = processEnv.PATH.split(path.delimiter);
1630-
}
1631-
// No PATH environment. Make path absolute to the cwd.
1632-
if (paths === undefined || paths.length === 0) {
1633-
return path.join(cwd, command);
1634-
}
1635-
// We have a simple file name. We get the path variable from the env
1636-
// and try to find the executable on the path.
1637-
for (let pathEntry of paths) {
1638-
// The path entry is absolute.
1639-
let fullPath: string;
1640-
if (path.isAbsolute(pathEntry)) {
1641-
fullPath = path.join(pathEntry, command);
1642-
} else {
1643-
fullPath = path.join(cwd, pathEntry, command);
1644-
}
1645-
1646-
if (await this.fileExists(fullPath)) {
1647-
return fullPath;
1648-
}
1649-
let withExtension = fullPath + '.com';
1650-
if (await this.fileExists(withExtension)) {
1651-
return withExtension;
1652-
}
1653-
withExtension = fullPath + '.exe';
1654-
if (await this.fileExists(withExtension)) {
1655-
return withExtension;
1656-
}
1657-
}
1658-
return path.join(cwd, command);
1659-
}
16601604
}

0 commit comments

Comments
 (0)