Skip to content

Commit

Permalink
Optimize getLatestNodeVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
KristjanESPERANTO committed Oct 25, 2024
1 parent d37e914 commit 5b9d29e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/io/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { coerce, gt, major } from 'semver'

function getLatestNodeVersion() {
const versions = Object.keys(nodeReleases)
const latestVersion = versions[versions.length - 1]
const latestVersion = versions.reduce((_prev, _curr) => {
const prev = coerce(_prev)
const curr = coerce(_curr)
return gt(curr, prev) ? _curr : _prev
})
return latestVersion
}

Expand Down

0 comments on commit 5b9d29e

Please sign in to comment.