mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-27 10:37:38 +01:00
@@ -454,6 +454,14 @@ export namespace win32 {
|
||||
if (paths === undefined || paths.length === 0) {
|
||||
return path.join(cwd, command);
|
||||
}
|
||||
|
||||
async function fileExists(path: string): Promise<boolean> {
|
||||
if (await promisify(fs.exists)(path)) {
|
||||
return !((await promisify(fs.stat)(path)).isDirectory);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// We have a simple file name. We get the path variable from the env
|
||||
// and try to find the executable on the path.
|
||||
for (let pathEntry of paths) {
|
||||
@@ -464,15 +472,15 @@ export namespace win32 {
|
||||
} else {
|
||||
fullPath = path.join(cwd, pathEntry, command);
|
||||
}
|
||||
if (await promisify(fs.exists)(fullPath)) {
|
||||
if (await fileExists(fullPath)) {
|
||||
return fullPath;
|
||||
}
|
||||
let withExtension = fullPath + '.com';
|
||||
if (await promisify(fs.exists)(withExtension)) {
|
||||
if (await fileExists(withExtension)) {
|
||||
return withExtension;
|
||||
}
|
||||
withExtension = fullPath + '.exe';
|
||||
if (await promisify(fs.exists)(withExtension)) {
|
||||
if (await fileExists(withExtension)) {
|
||||
return withExtension;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1420,6 +1420,14 @@ export class TerminalTaskSystem implements ITaskSystem {
|
||||
}
|
||||
}
|
||||
|
||||
private async fileExists(path: string): Promise<boolean> {
|
||||
const uri: URI = resources.toLocalResource(URI.from({ scheme: Schemas.file, path: path }), this.environmentService.configuration.remoteAuthority);
|
||||
if (await this.fileService.exists(uri)) {
|
||||
return !((await this.fileService.resolve(uri)).isDirectory);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private async findExecutable(command: string, cwd?: string, paths?: string[]): Promise<string> {
|
||||
// If we have an absolute path then we take it.
|
||||
if (path.isAbsolute(command)) {
|
||||
@@ -1452,15 +1460,15 @@ export class TerminalTaskSystem implements ITaskSystem {
|
||||
fullPath = path.join(cwd, pathEntry, command);
|
||||
}
|
||||
|
||||
if (await this.fileService.exists(resources.toLocalResource(URI.from({ scheme: Schemas.file, path: fullPath }), this.environmentService.configuration.remoteAuthority))) {
|
||||
if (await this.fileExists(fullPath)) {
|
||||
return fullPath;
|
||||
}
|
||||
let withExtension = fullPath + '.com';
|
||||
if (await this.fileService.exists(resources.toLocalResource(URI.from({ scheme: Schemas.file, path: withExtension }), this.environmentService.configuration.remoteAuthority))) {
|
||||
if (await this.fileExists(withExtension)) {
|
||||
return withExtension;
|
||||
}
|
||||
withExtension = fullPath + '.exe';
|
||||
if (await this.fileService.exists(resources.toLocalResource(URI.from({ scheme: Schemas.file, path: withExtension }), this.environmentService.configuration.remoteAuthority))) {
|
||||
if (await this.fileExists(withExtension)) {
|
||||
return withExtension;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user