Skip to content

Commit

Permalink
fix(manager/npm): don't warn for empty .yarnrc.yml (#20149)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Feb 1, 2023
1 parent fabb1bb commit d7d6d43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
11 changes: 11 additions & 0 deletions lib/modules/manager/npm/extract/yarnrc.spec.ts
Expand Up @@ -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()', () => {
Expand Down Expand Up @@ -91,6 +101,7 @@ describe('modules/manager/npm/extract/yarnrc', () => {
`,
null,
],
['', null],
])('produces expected config (%s)', (yarnrcYml, expectedConfig) => {
const config = loadConfigFromYarnrcYml(yarnrcYml);

Expand Down
13 changes: 8 additions & 5 deletions lib/modules/manager/npm/extract/yarnrc.ts
Expand Up @@ -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;
Expand Down

0 comments on commit d7d6d43

Please sign in to comment.