Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(cpanfile): support version ranges which are not v-prefixed (#22259)
  • Loading branch information
ikesyo committed May 17, 2023
1 parent 9a87c3f commit adacfcf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions lib/modules/manager/cpanfile/extract.spec.ts
Expand Up @@ -44,6 +44,13 @@ describe('modules/manager/cpanfile/extract', () => {
requires 'URI', '1.59';
requires 'HTTP::Tiny', 0.034;
requires "Capture::Tiny" => "0";
requires 'A', '== 1.1';
requires 'AA', '== v1.1';
requires 'B', '>= 1.2';
requires 'BB', '>= v1.2';
requires 'C', '> 1.3';
requires 'CC', '> v1.3';
`,
'cpanfile'
)
Expand All @@ -69,6 +76,36 @@ describe('modules/manager/cpanfile/extract', () => {
depName: 'Capture::Tiny',
currentValue: '0',
},
{
datasource: 'cpan',
depName: 'A',
currentValue: '1.1',
},
{
datasource: 'cpan',
depName: 'AA',
currentValue: '1.1',
},
{
datasource: 'cpan',
depName: 'B',
currentValue: '1.2',
},
{
datasource: 'cpan',
depName: 'BB',
currentValue: '1.2',
},
{
datasource: 'cpan',
depName: 'C',
currentValue: '1.3',
},
{
datasource: 'cpan',
depName: 'CC',
currentValue: '1.3',
},
],
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/cpanfile/parser.ts
Expand Up @@ -69,7 +69,7 @@ const moduleMatch = q
q.alt<Ctx>(q.op(','), q.op('=>')).alt(
q.num<Ctx>((ctx, { value: currentValue }) => ({ ...ctx, currentValue })),
q.str<Ctx>((ctx, { value }) => {
const currentValue = value.replace(/^(?:\s*(?:==|>=|>))?\s*v/, '');
const currentValue = value.replace(/^(?:\s*(?:==|>=|>))?\s*v?/, '');
return { ...ctx, currentValue };
})
)
Expand Down

0 comments on commit adacfcf

Please sign in to comment.