fix(crabbox): bootstrap absolute macOS env pnpm

This commit is contained in:
Vincent Koc
2026-06-16 04:58:47 +02:00
parent 2b05bd7b0d
commit 6da2d6ac5a
2 changed files with 110 additions and 11 deletions
+9 -8
View File
@@ -932,6 +932,7 @@ function stripShellExecutionPrefixes(wordsInput, options = {}) {
function stripEnvCommandOptions(words, { canShimIgnoreEnvironment = true } = {}) {
const originalWords = [...words];
const envCommand = words.shift() ?? "";
const canShimThisEnv = canShimIgnoreEnvironment && isSupportedSystemEnvCommand(envCommand);
let ignoresEnvironment = false;
for (;;) {
const word = words[0] ?? "";
@@ -976,7 +977,7 @@ function stripEnvCommandOptions(words, { canShimIgnoreEnvironment = true } = {})
return words.length > 0;
}
if (word === "-i" || word === "--ignore-environment") {
if (!canShimIgnoreEnvironment || envCommand.includes("/")) {
if (!canShimThisEnv) {
words.splice(0, words.length, ...originalWords);
return false;
}
@@ -997,7 +998,7 @@ function stripEnvCommandOptions(words, { canShimIgnoreEnvironment = true } = {})
}
if (word.startsWith("-") && word !== "-") {
if (word.includes("i")) {
if (!canShimIgnoreEnvironment || envCommand.includes("/")) {
if (!canShimThisEnv) {
words.splice(0, words.length, ...originalWords);
return false;
}
@@ -1006,7 +1007,7 @@ function stripEnvCommandOptions(words, { canShimIgnoreEnvironment = true } = {})
words.shift();
continue;
}
if (ignoresEnvironment && (!canShimIgnoreEnvironment || envCommand.includes("/"))) {
if (ignoresEnvironment && !canShimThisEnv) {
words.splice(0, words.length, ...originalWords);
return false;
}
@@ -1014,6 +1015,10 @@ function stripEnvCommandOptions(words, { canShimIgnoreEnvironment = true } = {})
}
}
function isSupportedSystemEnvCommand(command) {
return command === "env" || command === "/usr/bin/env";
}
function shellWordBasename(word) {
return (word ?? "").split("/").pop() ?? "";
}
@@ -1738,11 +1743,7 @@ function remoteAwsMacosJsBootstrap({ packageManager = false } = {}) {
}
function scopedAwsMacosEnvCommand(commandArgs) {
if (
commandArgs.length <= 1 ||
shellWordBasename(commandArgs[0]) !== "env" ||
commandArgs[0].includes("/")
) {
if (commandArgs.length <= 1 || !isSupportedSystemEnvCommand(commandArgs[0])) {
return null;
}