-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for nightly and rc versions #4
base: main
Are you sure you want to change the base?
Add support for nightly and rc versions #4
Conversation
src/installer.ts
Outdated
versions = versions.sort((a, b) => { | ||
if (semver.gt(a, b)) { | ||
return 1; | ||
} | ||
return -1; | ||
}); | ||
for (let i = versions.length - 1; i >= 0; i--) { | ||
const potential: string = versions[i]; | ||
const satisfied: boolean = semver.satisfies( | ||
potential.replace('-nightly', '-nightly.'), | ||
range, | ||
{includePrerelease: true} | ||
); | ||
if (satisfied) { | ||
version = potential; | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
versions = versions.sort((a, b) => { | |
if (semver.gt(a, b)) { | |
return 1; | |
} | |
return -1; | |
}); | |
for (let i = versions.length - 1; i >= 0; i--) { | |
const potential: string = versions[i]; | |
const satisfied: boolean = semver.satisfies( | |
potential.replace('-nightly', '-nightly.'), | |
range, | |
{includePrerelease: true} | |
); | |
if (satisfied) { | |
version = potential; | |
break; | |
} | |
} | |
versions.sort((a, b) => semver.lt(a, b) * 1 - 0.5); | |
for (const currentVersion of versions) { | |
const satisfied: boolean = semver.satisfies( | |
currentVersion.replace("-nightly", "-nightly."), | |
range, | |
{ includePrerelease: true } | |
); | |
if (satisfied) { | |
version = currentVersion; | |
break; | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uuuu @e-korolevskii has a few aces up in his sleeve :D
src/installer.ts
Outdated
} else if (!prerelease) { | ||
return 'https://nodejs.org/dist'; | ||
} else { | ||
return 'https://nodejs.org/download/rc'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if (!prerelease) { | |
return 'https://nodejs.org/dist'; | |
} else { | |
return 'https://nodejs.org/download/rc'; | |
} | |
} else if (prerelease) { | |
return 'https://nodejs.org/download/rc'; | |
} | |
return 'https://nodejs.org/dist'; |
src/installer.ts
Outdated
versions = versions.sort((a, b) => { | ||
if (semver.gt(a, b)) { | ||
return 1; | ||
} | ||
return -1; | ||
}); | ||
for (let i = versions.length - 1; i >= 0; i--) { | ||
const potential: string = versions[i]; | ||
const satisfied: boolean = semver.satisfies( | ||
potential.replace('-nightly', '-nightly.'), | ||
range, | ||
{includePrerelease: true} | ||
); | ||
if (satisfied) { | ||
version = potential; | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uuuu @e-korolevskii has a few aces up in his sleeve :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great, a couple of small suggestions
const prerelease = semver.prerelease(version); | ||
if (version.includes('nightly')) { | ||
return 'https://nodejs.org/download/nightly'; | ||
} else if (prerelease) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary else statement
} else if (prerelease) { | |
} | |
if (prerelease) { |
src/installer.ts
Outdated
} | ||
|
||
if (range) { | ||
versions.sort((a, b) => +semver.lt(a, b) * 1 - 0.5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary operation "* 1" because it is already being cast to a number by the "+" operator
versions.sort((a, b) => +semver.lt(a, b) * 1 - 0.5); | |
versions.sort((a, b) => +semver.lt(a, b) - 0.5); |
const prerelease = semver.prerelease(version); | ||
if (version.includes('nightly')) { | ||
return 'https://nodejs.org/download/nightly'; | ||
} else if (prerelease) { | ||
return 'https://nodejs.org/download/rc'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const prerelease = semver.prerelease(version); | |
if (version.includes('nightly')) { | |
return 'https://nodejs.org/download/nightly'; | |
} else if (prerelease) { | |
return 'https://nodejs.org/download/rc'; | |
} | |
if (version.includes('nightly')) { | |
return 'https://nodejs.org/download/nightly'; | |
} | |
const prerelease = semver.prerelease(version); | |
if (prerelease) { | |
return 'https://nodejs.org/download/rc'; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to declare this constant after the first conditional statement.
if (initialUrl.endsWith('/rc')) { | ||
return <im.INodeVersion>nodeTestDistRc; | ||
} else if (initialUrl.endsWith('/nightly')) { | ||
return <im.INodeVersion>nodeTestDistNightly; | ||
} else { | ||
return <im.INodeVersion>nodeTestDist; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (initialUrl.endsWith('/rc')) { | |
return <im.INodeVersion>nodeTestDistRc; | |
} else if (initialUrl.endsWith('/nightly')) { | |
return <im.INodeVersion>nodeTestDistNightly; | |
} else { | |
return <im.INodeVersion>nodeTestDist; | |
} | |
if (initialUrl.endsWith('/rc')) { | |
return <im.INodeVersion>nodeTestDistRc; | |
} | |
if (initialUrl.endsWith('/nightly')) { | |
return <im.INodeVersion>nodeTestDistNightly; | |
} | |
return <im.INodeVersion>nodeTestDist; |
Description:
Describe your changes.
Related issue:
Add link to the related issue.
Check list: