Skip to content

Commit

Permalink
Account for latest version when installing offline compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
delasy committed Feb 1, 2025
1 parent 1b9587c commit 49e2ab0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ function tempDirectory() {
}
exports.tempDirectory = tempDirectory;
function versionToNumber(version) {
if (['latest'].includes(version)) {
return Number.MAX_SAFE_INTEGER;
}
if (!version.match(/^\d+\.\d+\.\d+$/)) {
throw new Error(`Invalid version '${version}'`);
}
return version.split('.').reduce((acc, part) => {
return acc * 0x100 + parseInt(part);
}, 0);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export function tempDirectory (): string {
}

export function versionToNumber (version: string): number {
if (['latest'].includes(version)) {
return Number.MAX_SAFE_INTEGER
}

if (version.match(/^\d+\.\d+\.\d+$/) == null) {
throw new Error(`Invalid version '${version}'`)
}

return version.split('.').reduce((acc, part) => {
return acc * 0x100 + parseInt(part)
}, 0)
Expand Down

0 comments on commit 49e2ab0

Please sign in to comment.