提交 eb5044de 编写于 作者: J Jun Han

Fix #783: Not detect shell on Windows correctly

上级 cf6ecba6
......@@ -8,17 +8,11 @@
// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
"version": "2.0.0",
// we want to run npm
"command": "npm",
// the command is a shell script
"isShellCommand": true,
// show the output window only if unrecognized errors occur.
"showOutput": "silent",
// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],
......@@ -26,5 +20,21 @@
"isWatching": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
"problemMatcher": "$tsc-watch",
"tasks": [
{
"label": "npm",
"type": "shell",
"command": "npm",
"args": [
"run",
"compile",
"--loglevel",
"silent"
],
"isBackground": true,
"problemMatcher": "$tsc-watch",
"group": "build"
}
]
}
\ No newline at end of file
......@@ -32,9 +32,9 @@
"dev": true
},
"@types/vscode": {
"version": "1.54.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.54.0.tgz",
"integrity": "sha512-sHHw9HG4bTrnKhLGgmEiOS88OLO/2RQytUN4COX9Djv81zc0FSZsSiYaVyjNidDzUSpXsySKBkZ31lk2/FbdCg==",
"version": "1.56.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.56.0.tgz",
"integrity": "sha512-Q5VmQxOx+L1Y6lIJiGcJzwcyV3pQo/eiW8P+7sNLhFI16tJCwtua2DLjHRcpjbCLNVYpQM73kzfFo1Z0HyP9eQ==",
"dev": true
},
"ansi-colors": {
......
......@@ -10,7 +10,7 @@
"publisher": "formulahendry",
"icon": "images/logo.png",
"engines": {
"vscode": "^1.54.0"
"vscode": "^1.56.0"
},
"categories": [
"Programming Languages",
......@@ -363,7 +363,7 @@
"@types/micromatch": "^3.1.0",
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.40",
"@types/vscode": "^1.54.0",
"@types/vscode": "^1.56.0",
"mocha": "^6.1.4",
"tslint": "^5.5.0",
"typescript": "^3.8.3"
......
......@@ -388,45 +388,36 @@ export class CodeManager implements vscode.Disposable {
}
private changeExecutorFromCmdToPs(executor: string): string {
if (os.platform() === "win32") {
let windowsShell = vscode.workspace.getConfiguration("terminal").get<string>("integrated.shell.windows");
if (windowsShell === null) {
windowsShell = this.getTerminalDefaultShellWindows();
}
if (windowsShell && windowsShell.toLowerCase().indexOf("powershell") > -1 && executor.indexOf(" && ") > -1) {
let replacement = "; if ($?) {";
executor = executor.replace("&&", replacement);
replacement = "} " + replacement;
executor = executor.replace(/&&/g, replacement);
executor = executor.replace(/\$dir\$fileNameWithoutExt/g, ".\\$fileNameWithoutExt");
return executor + " }";
}
if (executor.includes(" && ") && this.isPowershellOnWindows()) {
let replacement = "; if ($?) {";
executor = executor.replace("&&", replacement);
replacement = "} " + replacement;
executor = executor.replace(/&&/g, replacement);
executor = executor.replace(/\$dir\$fileNameWithoutExt/g, ".\\$fileNameWithoutExt");
return executor + " }";
}
return executor;
}
/*
Workaround for https://github.com/formulahendry/vscode-code-runner/issues/491
The following code is based on https://github.com/microsoft/vscode-maven/commit/7c1dea723fe91f665c4e624e3bf71a411ceafd93
This is only a fall back to identify the default shell used by VSC.
*/
private getTerminalDefaultShellWindows(): string {
if (!this._TERMINAL_DEFAULT_SHELL_WINDOWS) {
const isAtLeastWindows10 = os.platform() === "win32" && parseFloat(os.release()) >= 10;
const is32ProcessOn64Windows = process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432");
const powerShellPath =
`${process.env.windir}\\${is32ProcessOn64Windows ? "Sysnative" : "System32"}\\WindowsPowerShell\\v1.0\\powershell.exe`;
this._TERMINAL_DEFAULT_SHELL_WINDOWS = isAtLeastWindows10 ? powerShellPath : this.getWindowsShell();
private isPowershellOnWindows(): boolean {
if (os.platform() === "win32") {
const defaultProfile = vscode.workspace.getConfiguration("terminal").get<string>("integrated.defaultProfile.windows");
if (defaultProfile) {
if (defaultProfile.toLowerCase().includes("powershell")) {
return true;
} else if (defaultProfile === "Command Prompt") {
return false;
}
}
const windowsShell = vscode.env.shell;
return (windowsShell && windowsShell.toLowerCase().includes("powershell"));
}
return this._TERMINAL_DEFAULT_SHELL_WINDOWS;
}
private getWindowsShell(): string {
return process.env.comspec || "cmd.exe";
return false;
}
private changeFilePathForBashOnWindows(command: string): string {
if (os.platform() === "win32") {
const windowsShell = vscode.workspace.getConfiguration("terminal").get<string>("integrated.shell.windows");
const windowsShell = vscode.env.shell;
const terminalRoot = this._config.get<string>("terminalRoot");
if (windowsShell && terminalRoot) {
command = command
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册