Skip to content

Commit

Permalink
Update so values like 1 and 1.2 are constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
burritobill committed Sep 30, 2024
1 parent f11569c commit af86be4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/modules/versioning/devbox/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import devbox from '.';
describe('modules/versioning/devbox/index', () => {
it.each`
version | expected
${'1'} | ${true}
${'1'} | ${false}
${'01'} | ${false}
${'1.01'} | ${false}
${'1.1'} | ${true}
${'1.1'} | ${false}
${'1.3.0'} | ${true}
${'2.1.20'} | ${true}
${'v1.4'} | ${false}
${'V0.5'} | ${false}
${'3.5.0'} | ${true}
${'4.2.21.Final'} | ${false}
${'1234'} | ${true}
${'1234'} | ${false}
${'foo'} | ${false}
${'latest'} | ${false}
${''} | ${false}
Expand Down
8 changes: 5 additions & 3 deletions lib/modules/versioning/devbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ export const displayName = 'devbox';

export const supportsRanges = false;

const versionPattern = regEx(/^((\d|[1-9]\d*)(\.(\d|[1-9]\d*)){0,2})$/);
const validPattern = regEx(/^((\d|[1-9]\d*)(\.(\d|[1-9]\d*)){0,2})$/);
const versionPattern = regEx(/^((\d|[1-9]\d*)(\.(\d|[1-9]\d*)){2})$/);

class DevboxVersioningApi extends GenericVersioningApi {
protected _parse(version: string): GenericVersion | null {
const matches = versionPattern.exec(version);
const matches = validPattern.exec(version);
if (!matches) {
return null;
}
Expand All @@ -31,7 +32,8 @@ class DevboxVersioningApi extends GenericVersioningApi {
if (version === 'latest') {
return false;
}
return this.isValid(version);
const matches = versionPattern.exec(version);
return !!matches;
}

protected override _compare(version: string, other: string): number {
Expand Down

0 comments on commit af86be4

Please sign in to comment.