Skip to content

Commit

Permalink
Fix semver regex (#46)
Browse files Browse the repository at this point in the history
support for regex versions with more than 1 digit on the major
  • Loading branch information
amiiit authored May 19, 2022
1 parent 927effe commit e03ec73
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8772,7 +8772,7 @@ var __webpack_exports__ = {};


const bump = (version, bump) => {
const cleanVersionMatcher = version.match(/.*(\d+\.\d+\.\d+).*/);
const cleanVersionMatcher = version.match(/[^\d]*((\d+)\.(\d+)\.(\d+)).*/);
if (cleanVersionMatcher == null || cleanVersionMatcher[1] === null) {
throw new Error(`invalid semver: ${version}`);
}
Expand Down
1 change: 1 addition & 0 deletions src/bump.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('bump', () => {
expect(bump('1.2.3', 'patch')).toEqual('1.2.4')
expect(bump('1.2.3', 'minor')).toEqual('1.3.0')
expect(bump('1.2.3', 'major')).toEqual('2.0.0')
expect(bump('101.2.2', 'patch')).toEqual('101.2.3')
expect(bump('v1.2.3', 'major')).toEqual('2.0.0')
expect(bump('v1.2.3', 'minor')).toEqual('1.3.0')
expect(bump('v1.2.3--alpha3', 'minor')).toEqual('1.3.0')
Expand Down
2 changes: 1 addition & 1 deletion src/bump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {CommitMessageQueryResponse, MergeCommit} from "./QueryTypes";
export type Bump = 'major' | 'minor' | 'patch';

export const bump = (version: string, bump: Bump) => {
const cleanVersionMatcher = version.match(/.*(\d+\.\d+\.\d+).*/);
const cleanVersionMatcher = version.match(/[^\d]*((\d+)\.(\d+)\.(\d+)).*/);
if (cleanVersionMatcher == null || cleanVersionMatcher[1] === null) {
throw new Error(`invalid semver: ${version}`)
}
Expand Down

0 comments on commit e03ec73

Please sign in to comment.