Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

fix: Failed to resolve the Node executable path when it contains spaces #363

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 1 commit into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
| **(Deprecated)** `leetcode.enableShortcuts` | Specify whether the submit and test shortcuts in editor or not. | `true` |
| `leetcode.editor.shortcuts` | Specify the customized shorcuts in editors. Supported values are: `submit`, `test`, `solution` and `description`. | `["submit, test"]` |
| `leetcode.enableSideMode` | Specify whether `preview`, `solution` and `submission` tab should be grouped into the second editor column when solving a problem. | `true` |
| `leetcode.nodePath` | Specify the `Node.js` executable path. | `node` |
| `leetcode.nodePath` | Specify the `Node.js` executable path. for example, C:\Program Files\nodejs\node.exe | `node` |

## Want Help?

Expand Down
2 changes: 1 addition & 1 deletion docs/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
| **(Deprecated)** `leetcode.enableShortcuts` | 指定是否在 VS Code 编辑文件下方显示提交和测试的快捷按钮。 | `true` |
| `leetcode.editor.shortcuts` | 指定在编辑器内所自定义的快捷方式。可用的快捷方式有: `submit`, `test`, `solution`, `description`。 | `["submit, test"]` |
| `leetcode.enableSideMode` | 指定在解决一道题时,是否将`问题预览`、`高票答案`与`提交结果`窗口集中在编辑器的第二栏。 | `true` |
| `leetcode.nodePath` | 指定 `Node.js` 可执行文件的路径。 | `node` |
| `leetcode.nodePath` | 指定 `Node.js` 可执行文件的路径。如:C:\Program Files\nodejs\node.exe | `node` |

## 需要帮助?
在遇到任何问题时,可以先查看一下[疑难解答](https://github.com/jdneo/vscode-leetcode/wiki/%E7%96%91%E9%9A%BE%E8%A7%A3%E7%AD%94)以及[常见问题](https://github.com/jdneo/vscode-leetcode/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)寻求帮助。
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
"type": "string",
"default": "node",
"scope": "application",
"description": "The Node.js executable path."
"description": "The Node.js executable path. for example, C:\\Program Files\\nodejs\\node.exe"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/leetCodeExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class LeetCodeExecutor implements Disposable {
if (!await fse.pathExists(this.nodeExecutable)) {
throw new Error(`The Node.js executable does not exist on path ${this.nodeExecutable}`);
}
// Wrap the executable with "" to avoid space issue in the path.
this.nodeExecutable = `"${this.nodeExecutable}"`;
if (useWsl()) {
this.nodeExecutable = await toWslPath(this.nodeExecutable);
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/workspaceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export async function getActiveFilePath(uri?: vscode.Uri): Promise<string | unde

function isSubFolder(from: string, to: string): boolean {
const relative: string = path.relative(from, to);
return !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
if (relative === "") {
return true;
}
return !relative.startsWith("..") && !path.isAbsolute(relative);
}

enum OpenOption {
Expand Down