@@ -14,13 +14,11 @@ import { toWslPath, useWsl } from "./utils/wslUtils";
1414
1515class LeetCodeExecutor implements Disposable {
1616 private leetCodeRootPath : string ;
17- private leetCodeRootPathInWsl : string ;
1817 private nodeExecutable : string ;
1918 private configurationChangeListener : Disposable ;
2019
2120 constructor ( ) {
2221 this . leetCodeRootPath = path . join ( __dirname , ".." , ".." , "node_modules" , "vsc-leetcode-cli" ) ;
23- this . leetCodeRootPathInWsl = "" ;
2422 this . nodeExecutable = this . getNodePath ( ) ;
2523 this . configurationChangeListener = workspace . onDidChangeConfiguration ( ( event : ConfigurationChangeEvent ) => {
2624 if ( event . affectsConfiguration ( "leetcode.nodePath" ) ) {
@@ -29,18 +27,11 @@ class LeetCodeExecutor implements Disposable {
2927 } , this ) ;
3028 }
3129
32- public async getLeetCodeRootPath ( ) : Promise < string > { // not wrapped by ""
30+ public async getLeetCodeBinaryPath ( ) : Promise < string > {
3331 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" ) } "` ) } ` ;
3833 }
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" ) } "` ;
4435 }
4536
4637 public async meetRequirements ( ) : Promise < boolean > {
@@ -168,7 +159,7 @@ class LeetCodeExecutor implements Disposable {
168159
169160 public async getCompaniesAndTags ( ) : Promise < { companies : { [ key : string ] : string [ ] } , tags : { [ key : string ] : string [ ] } } > {
170161 // 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" ) ;
172163 const companiesTagsSrc : string = ( await fse . readFile ( companiesTagsPath , "utf8" ) ) . replace (
173164 "module.exports = plugin" ,
174165 "module.exports = { COMPONIES, TAGS }" ,
0 commit comments