@@ -15,23 +15,19 @@ import { isFile, normCasePath } from './externalDependencies';
15
15
import * as posix from './posixUtils' ;
16
16
import * as windows from './windowsUtils' ;
17
17
18
- const matchPythonBinFilename =
18
+ const matchStandardPythonBinFilename =
19
19
getOSType ( ) === OSType . Windows ? windows . matchPythonBinFilename : posix . matchPythonBinFilename ;
20
20
type FileFilterFunc = ( filename : string ) => boolean ;
21
21
22
22
/**
23
- * Returns `true` if path provided is likely a python executable.
23
+ * Returns `true` if path provided is likely a python executable than a folder path .
24
24
*/
25
25
export async function isPythonExecutable ( filePath : string ) : Promise < boolean > {
26
- const isMatch = matchPythonBinFilename ( filePath ) ;
27
- if ( ! isMatch ) {
28
- return false ;
29
- }
30
- // On Windows it's fair to assume a path ending with `.exe` denotes a file.
31
- if ( getOSType ( ) === OSType . Windows ) {
26
+ const isMatch = matchStandardPythonBinFilename ( filePath ) ;
27
+ if ( isMatch && getOSType ( ) === OSType . Windows ) {
28
+ // On Windows it's fair to assume a path ending with `.exe` denotes a file.
32
29
return true ;
33
30
}
34
- // For other operating systems verify if it's a file.
35
31
if ( await isFile ( filePath ) ) {
36
32
return true ;
37
33
}
@@ -83,7 +79,7 @@ export async function* iterPythonExecutablesInDir(
83
79
) : AsyncIterableIterator < DirEntry > {
84
80
const readDirOpts = {
85
81
...opts ,
86
- filterFile : matchPythonBinFilename ,
82
+ filterFile : matchStandardPythonBinFilename ,
87
83
} ;
88
84
const entries = await readDirEntries ( dirname , readDirOpts ) ;
89
85
for ( const entry of entries ) {
@@ -270,7 +266,7 @@ async function checkPythonExecutable(
270
266
filterFile ?: ( f : string | DirEntry ) => Promise < boolean > ;
271
267
} ,
272
268
) : Promise < boolean > {
273
- const matchFilename = opts . matchFilename || matchPythonBinFilename ;
269
+ const matchFilename = opts . matchFilename || matchStandardPythonBinFilename ;
274
270
const filename = typeof executable === 'string' ? executable : executable . filename ;
275
271
276
272
if ( ! matchFilename ( filename ) ) {
0 commit comments