@@ -14,13 +14,11 @@ import { toWslPath, useWsl } from "./utils/wslUtils";
14
14
15
15
class LeetCodeExecutor implements Disposable {
16
16
private leetCodeRootPath : string ;
17
- private leetCodeRootPathInWsl : string ;
18
17
private nodeExecutable : string ;
19
18
private configurationChangeListener : Disposable ;
20
19
21
20
constructor ( ) {
22
21
this . leetCodeRootPath = path . join ( __dirname , ".." , ".." , "node_modules" , "vsc-leetcode-cli" ) ;
23
- this . leetCodeRootPathInWsl = "" ;
24
22
this . nodeExecutable = this . getNodePath ( ) ;
25
23
this . configurationChangeListener = workspace . onDidChangeConfiguration ( ( event : ConfigurationChangeEvent ) => {
26
24
if ( event . affectsConfiguration ( "leetcode.nodePath" ) ) {
@@ -29,18 +27,11 @@ class LeetCodeExecutor implements Disposable {
29
27
} , this ) ;
30
28
}
31
29
32
- public async getLeetCodeRootPath ( ) : Promise < string > { // not wrapped by ""
30
+ public async getLeetCodeBinaryPath ( ) : Promise < string > {
33
31
if ( wsl . useWsl ( ) ) {
34
- if ( ! this . leetCodeRootPathInWsl ) {
35
- this . leetCodeRootPathInWsl = `${ await wsl . toWslPath ( this . leetCodeRootPath ) } ` ;
36
- }
37
- return `${ this . leetCodeRootPathInWsl } ` ;
32
+ return `${ await wsl . toWslPath ( `"${ path . join ( this . leetCodeRootPath , "bin" , "leetcode" ) } "` ) } ` ;
38
33
}
39
- return `${ this . leetCodeRootPath } ` ;
40
- }
41
-
42
- public async getLeetCodeBinaryPath ( ) : Promise < string > { // wrapped by ""
43
- return `"${ path . join ( await this . getLeetCodeRootPath ( ) , "bin" , "leetcode" ) } "` ;
34
+ return `"${ path . join ( this . leetCodeRootPath , "bin" , "leetcode" ) } "` ;
44
35
}
45
36
46
37
public async meetRequirements ( ) : Promise < boolean > {
@@ -168,7 +159,7 @@ class LeetCodeExecutor implements Disposable {
168
159
169
160
public async getCompaniesAndTags ( ) : Promise < { companies : { [ key : string ] : string [ ] } , tags : { [ key : string ] : string [ ] } } > {
170
161
// preprocess the plugin source
171
- const companiesTagsPath : string = path . join ( await leetCodeExecutor . getLeetCodeRootPath ( ) , "lib" , "plugins" , "company.js" ) ;
162
+ const companiesTagsPath : string = path . join ( this . leetCodeRootPath , "lib" , "plugins" , "company.js" ) ;
172
163
const companiesTagsSrc : string = ( await fse . readFile ( companiesTagsPath , "utf8" ) ) . replace (
173
164
"module.exports = plugin" ,
174
165
"module.exports = { COMPONIES, TAGS }" ,
0 commit comments