-
Notifications
You must be signed in to change notification settings - Fork 665
fixed use wsl feature (issue#509) #510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
428255d
fixed use wsl feature
LNKLEO 1034001
Update leetCodeExecutor.ts
LNKLEO f0d01f7
Update leetCodeExecutor.ts
LNKLEO f3ad33f
Update leetCodeExecutor.ts
LNKLEO 4066e02
Update leetCodeExecutor.ts
LNKLEO 96a5821
Update wslUtils.ts
LNKLEO 5e3e468
Merge branch 'master' into master
jdneo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,11 @@ import { toWslPath, useWsl } from "./utils/wslUtils"; | |
|
||
class LeetCodeExecutor implements Disposable { | ||
private leetCodeRootPath: string; | ||
private leetCodeRootPathInWsl: string; | ||
private nodeExecutable: string; | ||
private configurationChangeListener: Disposable; | ||
|
||
constructor() { | ||
this.leetCodeRootPath = path.join(__dirname, "..", "..", "node_modules", "vsc-leetcode-cli"); | ||
this.leetCodeRootPathInWsl = ""; | ||
this.nodeExecutable = this.getNodePath(); | ||
this.configurationChangeListener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => { | ||
if (event.affectsConfiguration("leetcode.nodePath")) { | ||
|
@@ -29,18 +27,11 @@ class LeetCodeExecutor implements Disposable { | |
}, this); | ||
} | ||
|
||
public async getLeetCodeRootPath(): Promise<string> { // not wrapped by "" | ||
public async getLeetCodeBinaryPath(): Promise<string> { | ||
if (wsl.useWsl()) { | ||
if (!this.leetCodeRootPathInWsl) { | ||
this.leetCodeRootPathInWsl = `${await wsl.toWslPath(this.leetCodeRootPath)}`; | ||
} | ||
return `${this.leetCodeRootPathInWsl}`; | ||
return `${yield wsl.toWslPath(`"${path.join(yield`"${this.leetCodeRootPath}"`, "bin", "leetcode")}"`)}`; | ||
} | ||
return `${this.leetCodeRootPath}`; | ||
} | ||
|
||
public async getLeetCodeBinaryPath(): Promise<string> { // wrapped by "" | ||
return `"${path.join(await this.getLeetCodeRootPath(), "bin", "leetcode")}"`; | ||
return `"${path.join(yield`"${this.leetCodeRootPath}"`, "bin", "leetcode")}"`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Orz |
||
} | ||
|
||
public async meetRequirements(): Promise<boolean> { | ||
|
@@ -168,7 +159,7 @@ class LeetCodeExecutor implements Disposable { | |
|
||
public async getCompaniesAndTags(): Promise<{ companies: { [key: string]: string[] }, tags: { [key: string]: string[] } }> { | ||
// preprocess the plugin source | ||
const companiesTagsPath: string = path.join(await leetCodeExecutor.getLeetCodeRootPath(), "lib", "plugins", "company.js"); | ||
const companiesTagsPath: string = path.join(await this.leetCodeRootPath, "lib", "plugins", "company.js"); | ||
const companiesTagsSrc: string = (await fse.readFile(companiesTagsPath, "utf8")).replace( | ||
"module.exports = plugin", | ||
"module.exports = { COMPONIES, TAGS }", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to have
yield
here