Skip to content
Snippets Groups Projects
Unverified Commit d7d6d43b authored by Michael Kriese's avatar Michael Kriese Committed by GitHub
Browse files

fix(manager/npm): don't warn for empty `.yarnrc.yml` (#20149)

parent fabb1bba
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,16 @@ describe('modules/manager/npm/extract/yarnrc', () => {
});
expect(registryUrl).toBeNull();
});
it('ignores missing scope registryServer', () => {
const registryUrl = resolveRegistryUrl('@scope/a-package', {
npmScopes: {
scope: {},
},
npmRegistryServer: 'https://private.example.com/npm',
});
expect(registryUrl).toBeNull();
});
});
describe('loadConfigFromYarnrcYml()', () => {
......@@ -91,6 +101,7 @@ describe('modules/manager/npm/extract/yarnrc', () => {
`,
null,
],
['', null],
])('produces expected config (%s)', (yarnrcYml, expectedConfig) => {
const config = loadConfigFromYarnrcYml(yarnrcYml);
......
......@@ -17,11 +17,14 @@ export type YarnConfig = z.infer<typeof YarnrcYmlSchema>;
export function loadConfigFromYarnrcYml(yarnrcYml: string): YarnConfig | null {
try {
return YarnrcYmlSchema.parse(
load(yarnrcYml, {
json: true,
})
);
const obj = load(yarnrcYml, {
json: true,
});
if (!obj) {
// emtpy yaml file
return null;
}
return YarnrcYmlSchema.parse(obj);
} catch (err) {
logger.warn({ yarnrcYml, err }, `Failed to load yarnrc file`);
return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment