@ttsc/vscode 0.17.1 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/install.js
CHANGED
|
@@ -18,23 +18,66 @@ function createCodeCommand(
|
|
|
18
18
|
args,
|
|
19
19
|
platform = process.platform,
|
|
20
20
|
env = process.env,
|
|
21
|
+
deps = {},
|
|
21
22
|
) {
|
|
22
23
|
if (platform === "win32") {
|
|
24
|
+
const launcher = findWindowsCodeCommand(env, deps);
|
|
23
25
|
return {
|
|
24
26
|
command: env.ComSpec || "cmd.exe",
|
|
25
|
-
args: ["/d", "/s", "/c", quoteWindowsCommand([
|
|
26
|
-
// The `/c` payload is
|
|
27
|
-
// each arg again unless told not to, turning `""code"
|
|
28
|
-
// `"\"\"code\"
|
|
29
|
-
// CVE-2024-27980 argument-escaping change
|
|
30
|
-
//
|
|
31
|
-
// `code …`.
|
|
27
|
+
args: ["/d", "/s", "/c", quoteWindowsCommand([launcher, ...args])],
|
|
28
|
+
// The `/c` payload is already fully quoted. Node's Windows spawn escapes
|
|
29
|
+
// each arg again unless told not to, turning `""code.cmd" ...` into
|
|
30
|
+
// `"\"\"code.cmd\" ...\""`, which cmd.exe sees as one un-runnable token
|
|
31
|
+
// after the CVE-2024-27980 argument-escaping change. Pass the payload
|
|
32
|
+
// verbatim so cmd's `/s` strips the outer quotes and runs `code.cmd ...`.
|
|
32
33
|
options: { windowsVerbatimArguments: true },
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
return { command: "code", args, options: {} };
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
function findWindowsCodeCommand(env = process.env, deps = {}) {
|
|
40
|
+
const existsSync = deps.existsSync ?? fs.existsSync;
|
|
41
|
+
const spawnSync = deps.spawnSync ?? cp.spawnSync;
|
|
42
|
+
const candidates = [];
|
|
43
|
+
const add = (candidate) => {
|
|
44
|
+
if (candidate && !candidates.includes(candidate)) candidates.push(candidate);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
for (const candidate of [
|
|
48
|
+
env.LOCALAPPDATA &&
|
|
49
|
+
path.win32.join(
|
|
50
|
+
env.LOCALAPPDATA,
|
|
51
|
+
"Programs",
|
|
52
|
+
"Microsoft VS Code",
|
|
53
|
+
"bin",
|
|
54
|
+
"code.cmd",
|
|
55
|
+
),
|
|
56
|
+
env.ProgramFiles &&
|
|
57
|
+
path.win32.join(env.ProgramFiles, "Microsoft VS Code", "bin", "code.cmd"),
|
|
58
|
+
env["ProgramFiles(x86)"] &&
|
|
59
|
+
path.win32.join(
|
|
60
|
+
env["ProgramFiles(x86)"],
|
|
61
|
+
"Microsoft VS Code",
|
|
62
|
+
"bin",
|
|
63
|
+
"code.cmd",
|
|
64
|
+
),
|
|
65
|
+
]) {
|
|
66
|
+
add(candidate);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const where = spawnSync("where.exe", ["code.cmd"], {
|
|
70
|
+
encoding: "utf8",
|
|
71
|
+
env,
|
|
72
|
+
windowsHide: true,
|
|
73
|
+
});
|
|
74
|
+
if (!where.error && typeof where.stdout === "string") {
|
|
75
|
+
for (const line of where.stdout.split(/\r?\n/)) add(line.trim());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return candidates.find((candidate) => existsSync(candidate)) ?? "code.cmd";
|
|
79
|
+
}
|
|
80
|
+
|
|
38
81
|
function quoteWindowsCommand(args) {
|
|
39
82
|
return `"${args.map(quoteWindowsArg).join(" ")}"`;
|
|
40
83
|
}
|
|
@@ -114,6 +157,7 @@ if (require.main === module) {
|
|
|
114
157
|
|
|
115
158
|
module.exports = {
|
|
116
159
|
createCodeCommand,
|
|
160
|
+
findWindowsCodeCommand,
|
|
117
161
|
findVsix,
|
|
118
162
|
main,
|
|
119
163
|
quoteWindowsCommand,
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@ttsc/vscode",
|
|
3
3
|
"displayName": "ttsc",
|
|
4
4
|
"description": "Show ttsc plugin diagnostics in VS Code, with @ttsc/lint errors, fix-all actions, and formatter support.",
|
|
5
|
-
"version": "0.17.
|
|
5
|
+
"version": "0.17.2",
|
|
6
6
|
"publisher": "samchon",
|
|
7
7
|
"icon": "images/icon.png",
|
|
8
8
|
"license": "MIT",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"rimraf": "^6.1.2",
|
|
106
106
|
"typescript": "7.0.1-rc",
|
|
107
107
|
"vscode-languageclient": "^9.0.1",
|
|
108
|
-
"ttsc": "0.17.
|
|
108
|
+
"ttsc": "0.17.2"
|
|
109
109
|
},
|
|
110
110
|
"scripts": {
|
|
111
111
|
"build": "rimraf lib dist && node build/build.cjs"
|