mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Merge pull request #137 from AikidoSec/remove-yarn-version-check
This commit is contained in:
commit
fa0cc710ef
2 changed files with 4 additions and 26 deletions
|
|
@ -35,29 +35,7 @@ export async function runYarnCommand(args) {
|
|||
async function fixYarnProxyEnvironmentVariables(env) {
|
||||
// Yarn ignores standard proxy environment variable HTTPS_PROXY
|
||||
// It does respect NODE_EXTRA_CA_CERTS for custom CA certificates though.
|
||||
// Don't use YARN_HTTPS_CA_FILE_PATH though, as it causes to ignore all system CAs
|
||||
// Don't use YARN_HTTPS_CA_FILE_PATH or YARN_CA_FILE_PATH though, it causes yarn to ignore all system CAs
|
||||
|
||||
// Yarn v2/v3 and v4+ use different environment variables for proxy and CA certs
|
||||
// When setting all variables, yarn returns an error about conflicting variables
|
||||
// - v2/v3: "Usage Error: Unrecognized or legacy configuration settings found: httpsCaFilePath"
|
||||
// - v4+: "Usage Error: Unrecognized or legacy configuration settings found: caFilePath"
|
||||
|
||||
const version = await yarnVersion();
|
||||
const majorVersion = parseInt(version.split(".")[0]);
|
||||
|
||||
if (majorVersion >= 4) {
|
||||
env.YARN_HTTPS_PROXY = env.HTTPS_PROXY;
|
||||
} else if (majorVersion === 2 || majorVersion === 3) {
|
||||
env.YARN_HTTPS_PROXY = env.HTTPS_PROXY;
|
||||
}
|
||||
}
|
||||
|
||||
async function yarnVersion() {
|
||||
const result = await safeSpawn("yarn", ["--version"], {
|
||||
stdio: "pipe",
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
throw new Error("Failed to get yarn version");
|
||||
}
|
||||
return result.stdout.trim();
|
||||
env.YARN_HTTPS_PROXY = env.HTTPS_PROXY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,13 +103,13 @@ describe("runYarnCommand", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("should not set Yarn-specific proxy vars for Yarn v1", async () => {
|
||||
it("should set YARN_HTTPS_PROXY for Yarn v1", async () => {
|
||||
yarnVersion = "1.22.19";
|
||||
await runYarnCommand(["add", "lodash"]);
|
||||
|
||||
assert.strictEqual(
|
||||
capturedEnv.YARN_HTTPS_PROXY,
|
||||
undefined,
|
||||
"http://localhost:8080",
|
||||
"YARN_HTTPS_PROXY should not be set for Yarn v1"
|
||||
);
|
||||
assert.strictEqual(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue