From c71623844f9289439ca59ad9e6569274deb06eda Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 14 Aug 2024 14:32:00 -0700 Subject: [PATCH] fix: Support nullable strictSSL --- src/utils.ts | 2 +- tests/unit/src/__snapshots__/utils.spec.ts.snap | 10 +++++----- tests/unit/src/utils.spec.ts | 8 ++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 6573674..9d0d587 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -131,7 +131,7 @@ export function getNpmConfig(runnerConfig: NpmConfigContainer) { } const cfg: { [key: string]: string | boolean | null } = { registry: runnerConfig.npm.registry || getDefaultRegistry(), - 'strict-ssl': runnerConfig.npm.strictSSL !== false, + 'strict-ssl': runnerConfig.npm.strictSSL ?? null, // Setting to false to avoid dealing with the generated file. 'package-lock': runnerConfig.npm.packageLock === true, 'legacy-peer-deps': diff --git a/tests/unit/src/__snapshots__/utils.spec.ts.snap b/tests/unit/src/__snapshots__/utils.spec.ts.snap index ce35549..f2655fc 100644 --- a/tests/unit/src/__snapshots__/utils.spec.ts.snap +++ b/tests/unit/src/__snapshots__/utils.spec.ts.snap @@ -111,7 +111,7 @@ exports[`utils .prepareNpmEnv should use default registry 1`] = ` "package-lock": false, "registry": "https://registry.npmjs.org", "save": false, - "strict-ssl": true, + "strict-ssl": null, "update-notifier": false, }, ] @@ -133,7 +133,7 @@ exports[`utils .prepareNpmEnv should use env var for registry 1`] = ` "package-lock": false, "registry": "npmland.io", "save": false, - "strict-ssl": true, + "strict-ssl": null, "update-notifier": false, }, ] @@ -179,7 +179,7 @@ exports[`utils .prepareNpmEnv should use true as the default value for strictSSL "package-lock": false, "registry": "https://registry.npmjs.org", "save": false, - "strict-ssl": true, + "strict-ssl": null, "update-notifier": false, }, ] @@ -201,7 +201,7 @@ exports[`utils .prepareNpmEnv should use true as the default value for strictSSL "package-lock": false, "registry": "https://registry.npmjs.org", "save": false, - "strict-ssl": true, + "strict-ssl": null, "update-notifier": false, }, ] @@ -223,7 +223,7 @@ exports[`utils .prepareNpmEnv should use user registry 1`] = ` "package-lock": false, "registry": "registryland.io", "save": false, - "strict-ssl": true, + "strict-ssl": null, "update-notifier": false, }, ] diff --git a/tests/unit/src/utils.spec.ts b/tests/unit/src/utils.spec.ts index 1031722..8853d99 100644 --- a/tests/unit/src/utils.spec.ts +++ b/tests/unit/src/utils.spec.ts @@ -56,9 +56,9 @@ describe('utils', function () { expect(npmConfig).toHaveProperty('package-lock'); }); - it('should set strictSSL to true by default', function () { + it('should set strictSSL to null if not set', function () { const npmConfig = getNpmConfig(emptyConfig); - expect(npmConfig).toHaveProperty('strict-ssl', true); + expect(npmConfig).toHaveProperty('strict-ssl', null); }); it('should set strictSSL from runner config', function () { @@ -74,10 +74,6 @@ describe('utils', function () { runnerConfig.npm.strictSSL = true; npmConfig = getNpmConfig(runnerConfig); expect(npmConfig).toHaveProperty('strict-ssl', true); - - runnerConfig.npm.strictSSL = 'truthy?'; - npmConfig = getNpmConfig(runnerConfig); - expect(npmConfig).toHaveProperty('strict-ssl', true); }); it('should set packageLock to false by default', function () {