Skip to content

Commit

Permalink
fix: Support nullable strictSSL
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng92 committed Aug 14, 2024
1 parent 5f8d9d8 commit c716238
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/src/__snapshots__/utils.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
]
Expand All @@ -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,
},
]
Expand Down Expand Up @@ -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,
},
]
Expand All @@ -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,
},
]
Expand All @@ -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,
},
]
Expand Down
8 changes: 2 additions & 6 deletions tests/unit/src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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 () {
Expand Down

0 comments on commit c716238

Please sign in to comment.