Remove the normalisation bits added in error

This commit is contained in:
James McMeeking 2026-05-08 11:25:07 +01:00
parent 5f56114185
commit 55f2123f5c
No known key found for this signature in database
GPG key ID: C69A11061EE15228
2 changed files with 6 additions and 44 deletions

View file

@ -9,7 +9,7 @@ import { reportCommandExecutionFailure } from "../_shared/commandErrors.js";
*/
export async function runRushCommand(executableName, args) {
try {
const env = normalizeProxyEnvironmentVariables(
const env = prepareRushEnvironmentVariables(
mergeSafeChainProxyEnvironmentVariables(process.env),
);
@ -25,48 +25,17 @@ export async function runRushCommand(executableName, args) {
}
/**
* Ensure proxy settings are visible to package manager variants that rely on
* lowercase or npm/yarn-specific environment variables.
*
* @param {Record<string, string>} env
* @returns {Record<string, string>}
*/
function normalizeProxyEnvironmentVariables(env) {
const normalized = {
function prepareRushEnvironmentVariables(env) {
const prepared = {
...env,
};
if (normalized.HTTPS_PROXY && !normalized.HTTP_PROXY) {
normalized.HTTP_PROXY = normalized.HTTPS_PROXY;
if (prepared.HTTPS_PROXY && !prepared.HTTP_PROXY) {
prepared.HTTP_PROXY = prepared.HTTPS_PROXY;
}
if (normalized.HTTP_PROXY && !normalized.http_proxy) {
normalized.http_proxy = normalized.HTTP_PROXY;
}
if (normalized.HTTPS_PROXY && !normalized.https_proxy) {
normalized.https_proxy = normalized.HTTPS_PROXY;
}
if (normalized.HTTP_PROXY && !normalized.npm_config_proxy) {
normalized.npm_config_proxy = normalized.HTTP_PROXY;
}
if (normalized.HTTPS_PROXY && !normalized.npm_config_https_proxy) {
normalized.npm_config_https_proxy = normalized.HTTPS_PROXY;
}
if (normalized.HTTP_PROXY && !normalized.NPM_CONFIG_PROXY) {
normalized.NPM_CONFIG_PROXY = normalized.HTTP_PROXY;
}
if (normalized.HTTPS_PROXY && !normalized.NPM_CONFIG_HTTPS_PROXY) {
normalized.NPM_CONFIG_HTTPS_PROXY = normalized.HTTPS_PROXY;
}
if (normalized.HTTPS_PROXY && !normalized.YARN_HTTPS_PROXY) {
normalized.YARN_HTTPS_PROXY = normalized.HTTPS_PROXY;
}
return normalized;
return prepared;
}

View file

@ -75,13 +75,6 @@ describe("runRushCommand", () => {
assert.strictEqual(options.stdio, "inherit");
assert.strictEqual(options.env.HTTPS_PROXY, "http://localhost:8080");
assert.strictEqual(options.env.HTTP_PROXY, "http://localhost:8080");
assert.strictEqual(options.env.https_proxy, "http://localhost:8080");
assert.strictEqual(options.env.http_proxy, "http://localhost:8080");
assert.strictEqual(options.env.npm_config_https_proxy, "http://localhost:8080");
assert.strictEqual(options.env.npm_config_proxy, "http://localhost:8080");
assert.strictEqual(options.env.NPM_CONFIG_HTTPS_PROXY, "http://localhost:8080");
assert.strictEqual(options.env.NPM_CONFIG_PROXY, "http://localhost:8080");
assert.strictEqual(options.env.YARN_HTTPS_PROXY, "http://localhost:8080");
assert.ok(mergeCalls.length >= 1, "proxy env merge should be called");
});