-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use shell for execution of .cmd (tsp-server.cmd) (#4430)
fixes #4343. shell needs to be used for executing .cmd file in newer nodejs version (a breaking change from nodejs security release). more detail can be found in the issue.
- Loading branch information
Showing
3 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
changeKind: fix | ||
packages: | ||
- typespec-vscode | ||
--- | ||
|
||
Use "shell" when spawning execution of .cmd file(i.e. tsp-server.cmd) in windows |
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,4 +1,26 @@ | ||
import { Executable } from "vscode-languageclient/node.js"; | ||
|
||
/** normalize / and \\ to / */ | ||
export function normalizeSlash(str: string): string { | ||
return str.replaceAll(/\\/g, "/"); | ||
} | ||
|
||
/** | ||
* | ||
* @param exe | ||
* @param win32Only only use Shell when the process.platform is "win32" | ||
* @returns | ||
*/ | ||
export function useShellInExec(exe: Executable, win32Only: boolean = true): Executable { | ||
if (!win32Only || process.platform === "win32") { | ||
if (exe.options) { | ||
exe.options.shell = true; | ||
} else { | ||
exe.options = { shell: true }; | ||
} | ||
if (exe.command.includes(" ")) { | ||
exe.command = `"${exe.command}"`; | ||
} | ||
} | ||
return exe; | ||
} |