diff --git a/src/vs/base/node/processes.ts b/src/vs/base/node/processes.ts index 48972b3e9bddd2520592526c560530c3aac1e2d6..b6f7742e2b3cb61e683337d69b3ecfa1449b194f 100644 --- a/src/vs/base/node/processes.ts +++ b/src/vs/base/node/processes.ts @@ -454,6 +454,14 @@ export namespace win32 { if (paths === undefined || paths.length === 0) { return path.join(cwd, command); } + + async function fileExists(path: string): Promise { + 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; } } diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index 243e94fe789e9c59c37e62e56f16d02d7ac3baec..13ccdbe484447459b73aa3cbd228bbca3f32a72e 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -1420,6 +1420,14 @@ export class TerminalTaskSystem implements ITaskSystem { } } + private async fileExists(path: string): Promise { + 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 { // 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; } }