Skip to content

Commit

Permalink
Merge pull request #618 from salesforcecli/ew/npm-registry
Browse files Browse the repository at this point in the history
Look for SF_NPM_REGISTRY
  • Loading branch information
WillieRuemmele authored Oct 11, 2023
2 parents fcc8e57 + 104f2f9 commit 2dbb79f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/commands/plugins/trust/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class Verify extends SfCommand<VerifyResponse> {
vConfig.verifier = Verify.getVerifier(npmName, configContext);

if (flags.registry) {
process.env.SF_NPM_REGISTRY = flags.registry;
process.env.SFDX_NPM_REGISTRY = flags.registry;
}

Expand Down
3 changes: 2 additions & 1 deletion src/shared/installationVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions test/shared/installationVerification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2dbb79f

Please sign in to comment.