Skip to content

Commit

Permalink
fix: Failed to resolve the Node executable path when it contains spac…
Browse files Browse the repository at this point in the history
…es (#363)
  • Loading branch information
jdneo authored Jul 11, 2019
1 parent 453c51a commit 1798edd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
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

0 comments on commit 1798edd

Please sign in to comment.