Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

support WSL#46

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jdneo merged 5 commits intoLeetCode-OpenSource:masterfrompurocean:master
Jul 24, 2018
Merged

support WSL#46

jdneo merged 5 commits intoLeetCode-OpenSource:masterfrompurocean:master
Jul 24, 2018

Conversation

purocean
Copy link
Contributor

@puroceanpurocean commentedJul 21, 2018
edited by jdneo
Loading

resolve#47

@jdneo
Copy link
Member

@purocean Thank you for the contribution. I'll take a look at this PR these days.

}

export function toWinPath(path: string): string {
return cp.execFileSync("wsl", ["--", "wslpath", "-w", path]).toString().trim();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It looks the 1st param "--" doesn't work for me.

CMD>wsl wslpath -w /mnt/c/C:\
CMD>wsl -- wslpath -w /mnt/c//bin/bash: --: invalid optionUsage:  /bin/bash [GNU long option] [option] ...        /bin/bash [GNU long option] [option] script-file ...GNU long options:        --debug        --debugger        --dump-po-strings        --dump-strings        --help        --init-file        --login        --noediting        --noprofile        --norc        --posix        --rcfile        --restricted        --verbose        --versionShell options:        -ilrsD or -c command or -O shopt_option         (invocation only)        -abefhkmnptuvxBCHP or -o option

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please check the Windows version, maybe this param can be removed.

C:\>verMicrosoft Windows [Version 10.0.17713.1000]C:\>wsl --helpUsage: wsl.exe [option] ...Options:    -d, --distribution <DistributionName>        Launch the specified distribition.    -e, --exec <CommandLine>        Execute the specified Linux command. The remainder of the arguments are        used as the command line to execute.    -u, --user <UserName>        Run as the specified user.    --help        Display this usage information.    --        Stop parsing arguments and pass the remainder to the Linux process.C:\>wsl -- wslpath -u "C:/"/mnt/c/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Attaching mine.

C:\>verMicrosoft Windows [Version 10.0.17134.167]C:\>wsl --help/bin/bash: --: invalid optionUsage:  /bin/bash [GNU long option] [option] ...        /bin/bash [GNU long option] [option] script-file ...GNU long options:        --debug        --debugger        --dump-po-strings        --dump-strings        --help        --init-file        --login        --noediting        --noprofile        --norc        --posix        --rcfile        --restricted        --verbose        --versionShell options:        -ilrsD or -c command or -O shopt_option         (invocation only)        -abefhkmnptuvxBCHP or -o option

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I thinkwsl.exe is a wrapper to run inner shell in your WSL. I suppose the parameters depend on what your inner shell is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@purocean If you remove the-- at your side, will this command still workable?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

package.json Outdated
"type": "boolean",
"default": false,
"scope": "window",
"description": "Use nodejs inside the Windows Subsystem for Linux."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nodejs -> Node.js

@jdneo
Copy link
Member

Looks like there are several places which contains the logic likewsl.useWsl() ? wsl.toWslPath(workFolder) : workFolder.

I think it could be better to have a pathUtils that wrap this kind of logic there.@purocean what do you think?

}

export function toWslPath(path: string): string {
return cp.execFileSync("wsl", ["wslpath", "-u", `${path.replace(/\\/g, "/")}`]).toString().trim();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If we use" to wrap the path instead of replace\, will it be workable?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not Work :(

functiontoWslPath(path){returncp.execFileSync("wsl",["wslpath","-u",`"${path}"`]).toString().trim();}
module.js:549    throw err;    ^Error: Cannot find module '/mnt/y/env/VSCode-win32-x64/Y:/env/VSCode-win32-x64/.vscode/extensions/shengchen.vscode-leetcode-0.7.0/node_modules/leetcode-cli/bin/leetcode'    at Function.Module._resolveFilename (module.js:547:15)    at Function.Module._load (module.js:474:25)    at Function.Module.runMain (module.js:693:10)    at startup (bootstrap_node.js:191:16)    at bootstrap_node.js:612:3

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

WithpathUtils my point of view is not unnecessary at this time.

For this program, we just need do good job with file system and shell command for cross-platform. I think thecpUtils andworkspaceUtils is sufficiently abstract.

We can try to change these next time if needed.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We could focus oncpUtils andworkspaceUtils provide service for others.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@purocean That is because by default the optionshell ofexecFileSync is false. If add{shell: true} to the argument list, then I think it should work.

Another thing I'm concerning is that here we useexecFileSync(). Personally, I prefer useasync/await wherever possible. Take a look at this:https://nodejs.org/en/docs/guides/blocking-vs-non-blocking/
So can we use executeCommand in the cpUtils?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

{shell: true} work perfectly.

https://github.com/purocean/vscode-leetcode/blob/d330913ad843179e12d0248a155f8a1f570e9f6f/src/shared.ts#L7

We need a lot of works if we use async/await. Abstractleetcode command is a better option.

But we could improve step by step. Half a loaf is better than no bread.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

OK, make sense. Tracking issue:#48

@jdneojdneo merged commitb2deee8 intoLeetCode-OpenSource:masterJul 24, 2018
@jdneo
Copy link
Member

@purocean Merged, thank you.

ringcrl pushed a commit to ringcrl/vscode-leetcode that referenced this pull requestApr 21, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@EskibearEskibearEskibear left review comments

@jdneojdneojdneo approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Support WSL
3 participants
@purocean@jdneo@Eskibear

[8]ページ先頭

©2009-2025 Movatter.jp