


























@@ -118,6 +118,13 @@ function isExecutableFile(path, platform) {
118118function spawnInvocation(command, commandArgs, env, platform) {
119119const extension = extname(command).toLowerCase();
120120if (platform === "win32" && (extension === ".cmd" || extension === ".bat")) {
121+const nodeShim = resolveNodeCmdShim(command);
122+if (nodeShim) {
123+return {
124+command: nodeShim.node,
125+args: [nodeShim.script, ...commandArgs],
126+};
127+}
121128return {
122129command: resolveWindowsCmdExePath(env),
123130args: ["/d", "/s", "/c", buildBatchCommandLine(command, commandArgs)],
@@ -127,6 +134,28 @@ function spawnInvocation(command, commandArgs, env, platform) {
127134return { command, args: commandArgs };
128135}
129136137+function resolveNodeCmdShim(command) {
138+let content;
139+try {
140+content = readFileSync(command, "utf8");
141+} catch {
142+return null;
143+}
144+for (const rawLine of content.split(/\r?\n/u)) {
145+const line = rawLine.trim();
146+const match = /^"([^"]+node(?:\.exe)?)"\s+"%~dp0([^"]+)"\s+%\*$/iu.exec(line);
147+if (!match) {
148+continue;
149+}
150+const script = resolve(dirname(command), match[2]);
151+if (!isExecutableFile(script, process.platform)) {
152+continue;
153+}
154+return { node: match[1], script };
155+}
156+return null;
157+}
158+130159const cmdMetaCharactersRe = /([()\][%!^"`<>&|;, *?])/g;
131160const jsRuntimeEntrypoints = new Set([
132161"pnpm",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。