From 104f2f9395f24909d9ad45ac889755a63d48813e Mon Sep 17 00:00:00 2001 From: Eric Willhoit Date: Wed, 11 Oct 2023 14:39:23 -0500 Subject: [PATCH] fix: also look for SF_NPM_REGISTRY --- src/commands/plugins/trust/verify.ts | 1 + src/shared/installationVerification.ts | 3 ++- test/shared/installationVerification.test.ts | 19 +++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/commands/plugins/trust/verify.ts b/src/commands/plugins/trust/verify.ts index acfb0c65..90ac6bb2 100644 --- a/src/commands/plugins/trust/verify.ts +++ b/src/commands/plugins/trust/verify.ts @@ -66,6 +66,7 @@ export class Verify extends SfCommand { vConfig.verifier = Verify.getVerifier(npmName, configContext); if (flags.registry) { + process.env.SF_NPM_REGISTRY = flags.registry; process.env.SFDX_NPM_REGISTRY = flags.registry; } diff --git a/src/shared/installationVerification.ts b/src/shared/installationVerification.ts index 7560c28d..c6201184 100644 --- a/src/shared/installationVerification.ts +++ b/src/shared/installationVerification.ts @@ -151,7 +151,8 @@ const errorHandlerForVerify = (err: Error): Error => { return err; }; -export const getNpmRegistry = (): URL => new URL(process.env.SFDX_NPM_REGISTRY ?? DEFAULT_REGISTRY); +export const getNpmRegistry = (): URL => + new URL(process.env.SF_NPM_REGISTRY ?? process.env.SFDX_NPM_REGISTRY ?? DEFAULT_REGISTRY); /** * class for verifying a digital signature pack of an npm diff --git a/test/shared/installationVerification.test.ts b/test/shared/installationVerification.test.ts index 5e99fe54..9ea8a566 100644 --- a/test/shared/installationVerification.test.ts +++ b/test/shared/installationVerification.test.ts @@ -88,13 +88,24 @@ const getShelljsExecStub = ( }); describe('getNpmRegistry', () => { - const currentRegistry = process.env.SFDX_NPM_REGISTRY; + const currentSFRegistry = process.env.SF_NPM_REGISTRY; + const currentSFDXRegistry = process.env.SFDX_NPM_REGISTRY; after(() => { - if (currentRegistry) { - process.env.SFDX_NPM_REGISTRY = currentRegistry; + if (currentSFRegistry) { + process.env.SF_NPM_REGISTRY = currentSFRegistry; + } + if (currentSFDXRegistry) { + process.env.SFDX_NPM_REGISTRY = currentSFDXRegistry; } }); - it('set registry', () => { + it('set SF registry', () => { + const TEST_REG = 'https://registry.example.com/'; + process.env.SF_NPM_REGISTRY = TEST_REG; + const reg = getNpmRegistry(); + expect(reg.href).to.be.equal(TEST_REG); + }); + it('set SFDX registry', () => { + delete process.env.SF_NPM_REGISTRY; const TEST_REG = 'https://registry.example.com/'; process.env.SFDX_NPM_REGISTRY = TEST_REG; const reg = getNpmRegistry();