Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support unset strictSSL setting #76

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type NpmConfig = {
*/
registry?: string;
registries?: Registry[];
strictSSL?: boolean | string | null;
strictSSL?: boolean | null;
packageLock?: boolean | string | null;
packages?: { [key: string]: string | number };
legacyPeerDeps?: boolean | string | null;
Expand Down
5 changes: 2 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export async function setUpNpmConfig(
fund: false,
noproxy: 'registry.npmjs.org',
'package-lock': false,
'strict-ssl': true,
registry: getDefaultRegistry(),
'update-notifier': false,
};
Expand Down Expand Up @@ -129,9 +128,9 @@ export function getNpmConfig(runnerConfig: NpmConfigContainer) {
if (runnerConfig.npm === undefined) {
return {};
}
const cfg: { [key: string]: string | boolean | null } = {
const cfg: { [key: string]: string | boolean | null | undefined } = {
registry: runnerConfig.npm.registry || getDefaultRegistry(),
'strict-ssl': runnerConfig.npm.strictSSL !== false,
'strict-ssl': runnerConfig.npm.strictSSL,
// 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": undefined,
"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": undefined,
"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": undefined,
"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": undefined,
"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": undefined,
"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 undefined if not set', function () {
const npmConfig = getNpmConfig(emptyConfig);
expect(npmConfig).toHaveProperty('strict-ssl', true);
expect(npmConfig).toHaveProperty('strict-ssl', undefined);
});

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