




























@@ -5,6 +5,11 @@ import path from "node:path";
55import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../plugins/runtime-sidecar-paths.js";
66import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
77import { pathExists } from "../utils.js";
8+import {
9+applyPosixNpmScriptShellEnv,
10+hasNpmScriptShellSetting,
11+resolvePosixNpmScriptShell,
12+} from "./npm-install-env.js";
813import {
914collectPackageDistInventory,
1015PACKAGE_DIST_INVENTORY_RELATIVE_PATH,
@@ -41,7 +46,6 @@ const NPM_GLOBAL_INSTALL_OMIT_OPTIONAL_FLAGS = [
4146"--omit=optional",
4247 ...NPM_GLOBAL_INSTALL_QUIET_FLAGS,
4348] as const;
44-const NPM_CONFIG_SCRIPT_SHELL_KEYS = ["NPM_CONFIG_SCRIPT_SHELL", "npm_config_script_shell"];
4549const FIRST_PACKAGED_DIST_INVENTORY_VERSION = { major: 2026, minor: 4, patch: 15 };
4650const OMITTED_PRIVATE_QA_BUNDLED_PLUGIN_ROOTS = new Set([
4751"dist/extensions/qa-channel",
@@ -316,31 +320,6 @@ function applyCorepackDownloadPromptEnv(env: Record<string, string>) {
316320}
317321}
318322319-function hasNpmScriptShellSetting(env: NodeJS.ProcessEnv): boolean {
320-return NPM_CONFIG_SCRIPT_SHELL_KEYS.some((key) => Boolean(env[key]?.trim()));
321-}
322-323-function resolvePosixNpmScriptShell(env: NodeJS.ProcessEnv): string | null {
324-if (process.platform === "win32") {
325-return null;
326-}
327-if (fsSync.existsSync("/bin/sh")) {
328-return "/bin/sh";
329-}
330-const shell = env.SHELL?.trim();
331-return shell && path.isAbsolute(shell) && fsSync.existsSync(shell) ? shell : null;
332-}
333-334-function applyPosixNpmScriptShellEnv(env: Record<string, string>) {
335-if (hasNpmScriptShellSetting(env)) {
336-return;
337-}
338-const scriptShell = resolvePosixNpmScriptShell(env);
339-if (scriptShell) {
340-env.NPM_CONFIG_SCRIPT_SHELL = scriptShell;
341-}
342-}
343-344323export function resolveGlobalInstallSpec(params: {
345324packageName: string;
346325tag: string;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。