Skip to content

Commit

Permalink
fix(versioning/hashicorp): allow numbered unstable versions (#21334)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Apr 4, 2023
1 parent fb71c81 commit 88f6b98
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/modules/versioning/hashicorp/convertor.spec.ts
Expand Up @@ -18,6 +18,7 @@ describe('modules/versioning/hashicorp/convertor', () => {
${'< 4.0'} | ${'<4.0'}
${'> 4.0, < 5.0'} | ${'>4.0 <5.0'}
${'~> 2.3.4'} | ${'~2.3.4'}
${'0.1.0-beta.0'} | ${'0.1.0-beta.0'}
`(
'hashicorp2npm("$hashicorp") === $npm && npm2hashicorp("$npm") === $hashicorp',
({ hashicorp, npm }) => {
Expand Down
6 changes: 4 additions & 2 deletions lib/modules/versioning/hashicorp/convertor.ts
Expand Up @@ -14,7 +14,9 @@ export function hashicorp2npm(input: string): string {
.split(',')
.map((single) => {
const r = single.match(
regEx(/^\s*(|=|!=|>|<|>=|<=|~>)\s*v?((\d+)(\.\d+){0,2}[\w-+]*)\s*$/)
regEx(
/^\s*(|=|!=|>|<|>=|<=|~>)\s*v?((\d+)(\.\d+){0,2}[\w-+]*(\.\d+)*)\s*$/
)
);
if (!r) {
logger.warn(
Expand Down Expand Up @@ -64,7 +66,7 @@ export function npm2hashicorp(input: string): string {
.split(' ')
.map((single) => {
const r = single.match(
regEx(/^(|>|<|>=|<=|~|\^)v?((\d+)(\.\d+){0,2}[\w-]*)$/)
regEx(/^(|>|<|>=|<=|~|\^)v?((\d+)(\.\d+){0,2}[\w-]*(\.\d+)*)$/)
);
if (!r) {
throw new Error('invalid npm constraint');
Expand Down
1 change: 1 addition & 0 deletions lib/modules/versioning/hashicorp/index.spec.ts
Expand Up @@ -36,6 +36,7 @@ describe('modules/versioning/hashicorp/index', () => {
${'>=4.1'} | ${true}
${'<=4.1.2'} | ${true}
${''} | ${false}
${'0.1.0-beta.0'} | ${true}
`('isValid("$input") === $expected', ({ input, expected }) => {
const res = !!semver.isValid(input);
expect(res).toBe(expected);
Expand Down

0 comments on commit 88f6b98

Please sign in to comment.