Skip to content

Commit

Permalink
fix: invalid version (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdx-xf authored Dec 8, 2023
1 parent 551b6b2 commit 5e38c28
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ export function colorizeVersionDiff(from: string, to: string, hightlightRange =
let i = partsToColor.findIndex((part, i) => part !== partsToCompare[i])
i = i >= 0 ? i : partsToColor.length

const diffType = getDiff(new SemVer(from), new SemVer(to))
let diffType = null
try {
diffType = getDiff(new SemVer(from), new SemVer(to))
}
catch (error) {
}
const color = DiffColorMap[diffType || 'patch']

// if we are colorizing only part of the word, add a dot in the middle
Expand All @@ -108,9 +113,9 @@ export function colorizeVersionDiff(from: string, to: string, hightlightRange =
: 'yellow'

return c[leadingColor](leadingWildcard)
+ partsToColor.slice(0, i).join('.')
+ middot
+ c[color](partsToColor.slice(i).join('.')).trim()
+ partsToColor.slice(0, i).join('.')
+ middot
+ c[color](partsToColor.slice(i).join('.')).trim()
}

interface SliceRenderLine {
Expand Down Expand Up @@ -168,9 +173,9 @@ export function createSliceRender() {
let slice: SliceRenderLine[]
if (
remainHeight < 1
|| remainLines.length === 0
|| remainLines.length <= remainHeight
|| lines.some(x => Math.ceil(visualLength(x.content) / availableWidth) > 1)
|| remainLines.length === 0
|| remainLines.length <= remainHeight
|| lines.some(x => Math.ceil(visualLength(x.content) / availableWidth) > 1)
) {
slice = remainLines
}
Expand Down

0 comments on commit 5e38c28

Please sign in to comment.