@@ -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,13 @@ class LeetCodeExecutor implements Disposable {
29
27
} , this ) ;
30
28
}
31
29
32
- public async getLeetCodeRootPath ( ) : Promise < string > { // not wrapped by ""
33
- if ( wsl . useWsl ( ) ) {
34
- if ( ! this . leetCodeRootPathInWsl ) {
35
- this . leetCodeRootPathInWsl = `${ await wsl . toWslPath ( this . leetCodeRootPath ) } ` ;
30
+ getLeetCodeBinaryPath ( ) {
31
+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
32
+ if ( wsl . useWsl ( ) ) {
33
+ return `${ yield wsl . toWslPath ( `" ${ path . join ( yield `" ${ this . leetCodeRootPath } "` , "bin" , "leetcode" ) } "` ) } ` ;
36
34
}
37
- return `${ this . leetCodeRootPathInWsl } ` ;
38
- }
39
- return `${ this . leetCodeRootPath } ` ;
40
- }
41
-
42
- public async getLeetCodeBinaryPath ( ) : Promise < string > { // wrapped by ""
43
- return `"${ path . join ( await this . getLeetCodeRootPath ( ) , "bin" , "leetcode" ) } "` ;
35
+ return `"${ path . join ( yield `"${ this . leetCodeRootPath } "` , "bin" , "leetcode" ) } "` ;
36
+ } ) ;
44
37
}
45
38
46
39
public async meetRequirements ( ) : Promise < boolean > {
@@ -168,7 +161,7 @@ class LeetCodeExecutor implements Disposable {
168
161
169
162
public async getCompaniesAndTags ( ) : Promise < { companies : { [ key : string ] : string [ ] } , tags : { [ key : string ] : string [ ] } } > {
170
163
// preprocess the plugin source
171
- const companiesTagsPath : string = path . join ( await leetCodeExecutor . getLeetCodeRootPath ( ) , "lib" , "plugins" , "company.js" ) ;
164
+ const companiesTagsPath : string = path . join ( await this . leetCodeRootPath , "lib" , "plugins" , "company.js" ) ;
172
165
const companiesTagsSrc : string = ( await fse . readFile ( companiesTagsPath , "utf8" ) ) . replace (
173
166
"module.exports = plugin" ,
174
167
"module.exports = { COMPONIES, TAGS }" ,
0 commit comments