Skip to content

Commit

Permalink
🐛 Fix sorting git tags
Browse files Browse the repository at this point in the history
  • Loading branch information
priestine committed Jul 3, 2020
1 parent 997a40a commit 1aed845
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/pure/getters/get-all-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ export const getAllTags = ({ execEither }: IDeps) => () => ({
// ------------------------------------------------------------------------------------------------

const bySemVer = (a: string, b: string): -1 | 0 | 1 => {
if (!/\d+.\d+.\d+/.test(a)) {
return 1
}

if (!/\d+.\d+.\d+/.test(b)) {
return -1
}

const aTuple: [number, number, number, string] = /(\d+)\.(\d+)\.(\d+)(.*)/
const aTuple: [number, number, number, string] = /(\d+)\.?(\d+)?\.?(\d+)?(.*)/
.exec(a)
?.slice(1, 5)
.map((n, i) => (i < 3 ? Number(n) : n)) as any
const bTuple: [number, number, number, string] = /(\d+)\.(\d+)\.(\d+)(.*)/

const bTuple: [number, number, number, string] = /(\d+)\.?(\d+)?\.?(\d+)?(.*)/
.exec(b)
?.slice(1, 5)
.map((n, i) => (i < 3 ? Number(n) : n)) as any
Expand Down

0 comments on commit 1aed845

Please sign in to comment.