@@ -72,7 +72,9 @@ export function isForbiddenStorePath(interpreterPath: string): boolean {
72
72
*/
73
73
export async function isWindowsStoreEnvironment ( interpreterPath : string ) : Promise < boolean > {
74
74
const pythonPathToCompare = path . normalize ( interpreterPath ) . toUpperCase ( ) ;
75
- const localAppDataStorePath = path . normalize ( getWindowsStoreAppsRoot ( ) ) . toUpperCase ( ) ;
75
+ const localAppDataStorePath = path
76
+ . normalize ( getWindowsStoreAppsRoot ( ) )
77
+ . toUpperCase ( ) ;
76
78
if ( pythonPathToCompare . includes ( localAppDataStorePath ) ) {
77
79
return true ;
78
80
}
@@ -96,7 +98,7 @@ export async function isWindowsStoreEnvironment(interpreterPath: string): Promis
96
98
* python3.exe
97
99
* python38.exe
98
100
*/
99
- const windowsPythonExes = 'python3\.[0-9]\.exe' ;
101
+ const windowsStorePythonExes = 'python3\.[0-9]\.exe' ;
100
102
101
103
/**
102
104
* Checks if a given path ends with python3.*.exe. Not all python executables are matched as
@@ -105,7 +107,7 @@ const windowsPythonExes = 'python3\.[0-9]\.exe';
105
107
* @returns {boolean } : Returns true if the path matches pattern for windows python executable.
106
108
*/
107
109
export function isWindowsStorePythonExe ( interpreterPath : string ) : boolean {
108
- const regex = picomatch . toRegex ( windowsPythonExes , { nocase : true } ) ;
110
+ const regex = picomatch . toRegex ( windowsStorePythonExes , { nocase : true } ) ;
109
111
return regex . test ( path . basename ( interpreterPath ) ) ;
110
112
}
111
113
@@ -130,15 +132,16 @@ export async function getWindowsStorePythonExes(): Promise<string[]> {
130
132
131
133
// Collect python*.exe directly under %LOCALAPPDATA%/Microsoft/WindowsApps
132
134
const files = await fsapi . readdir ( windowsAppsRoot ) ;
133
- return files . map ( ( filename : string ) => path . join ( windowsAppsRoot , filename ) ) . filter ( isWindowsStorePythonExe ) ;
135
+ return files
136
+ . map ( ( filename : string ) => path . join ( windowsAppsRoot , filename ) )
137
+ . filter ( isWindowsStorePythonExe ) ;
134
138
}
135
139
136
140
export class WindowsStoreLocator extends Locator {
137
141
private readonly kind : PythonEnvKind = PythonEnvKind . WindowsStore ;
138
142
139
- public constructor ( ) {
140
- super ( ) ;
141
- this . registerWatchers ( ) . ignoreErrors ( ) ;
143
+ public initialize ( ) : void {
144
+ this . startWatcher ( ) . ignoreErrors ( ) ;
142
145
}
143
146
144
147
public iterEnvs ( ) : IPythonEnvsIterator {
@@ -171,10 +174,10 @@ export class WindowsStoreLocator extends Locator {
171
174
return undefined ;
172
175
}
173
176
174
- private async registerWatchers ( ) : Promise < void > {
177
+ private async startWatcher ( ) : Promise < void > {
175
178
const windowsAppsRoot = getWindowsStoreAppsRoot ( ) ;
176
179
watchLocationForPythonBinaries ( windowsAppsRoot , ( type : FileChangeType ) => {
177
180
this . emitter . fire ( { type, kind : this . kind } ) ;
178
- } , windowsPythonExes ) ;
181
+ } , windowsStorePythonExes ) ;
179
182
}
180
183
}
0 commit comments