Skip to content

Commit a5f15d3

Browse files
committed
Temporarily switch to node FS apis in KnownPathsService (microsoft#11340)
* Update package lock * Use node FS API while looking for paths. * Use fs-extras instead
1 parent 03bfd82 commit a5f15d3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

news/2 Fixes/10850.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use node FS APIs when searching for python. This is a temporary change until VSC FS APIs are fixed.

src/client/interpreter/locators/helpers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as fsapi from 'fs-extra';
12
import { inject, injectable } from 'inversify';
23
import * as path from 'path';
34
import { traceError } from '../../common/logger';
@@ -8,13 +9,15 @@ import { IPipEnvServiceHelper } from './types';
89

910
const CheckPythonInterpreterRegEx = IS_WINDOWS ? /^python(\d+(.\d+)?)?\.exe$/ : /^python(\d+(.\d+)?)?$/;
1011

11-
export async function lookForInterpretersInDirectory(pathToCheck: string, fs: IFileSystem): Promise<string[]> {
12+
export async function lookForInterpretersInDirectory(pathToCheck: string, _: IFileSystem): Promise<string[]> {
1213
// Technically, we should be able to use fs.getFiles(). However,
1314
// that breaks some tests. So we stick with the broader behavior.
1415
try {
15-
const subDirs = await fs.listdir(pathToCheck);
16-
return subDirs
17-
.map(([filename, _ft]) => filename)
16+
// tslint:disable-next-line: no-suspicious-comment
17+
// TODO https://github.com/microsoft/vscode-python/issues/11338
18+
const files = await fsapi.readdir(pathToCheck);
19+
return files
20+
.map((filename) => path.join(pathToCheck, filename))
1821
.filter((fileName) => CheckPythonInterpreterRegEx.test(path.basename(fileName)));
1922
} catch (err) {
2023
traceError('Python Extension (lookForInterpretersInDirectory.fs.listdir):', err);

0 commit comments

Comments
 (0)