Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

dmitry-shibanov
Copy link

Description:
Describe your changes.

Related issue:
Add link to the related issue.

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

src/installer.ts Outdated
Comment on lines 386 to 403
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;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
}
}

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
Comment on lines 452 to 456
} else if (!prerelease) {
return 'https://nodejs.org/dist';
} else {
return 'https://nodejs.org/download/rc';
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} 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
Comment on lines 386 to 403
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;
}
}

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

Copy link

@e-korolevskii e-korolevskii left a 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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary else statement

Suggested change
} else if (prerelease) {
}
if (prerelease) {

src/installer.ts Outdated
}

if (range) {
versions.sort((a, b) => +semver.lt(a, b) * 1 - 0.5);

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

Suggested change
versions.sort((a, b) => +semver.lt(a, b) * 1 - 0.5);
versions.sort((a, b) => +semver.lt(a, b) - 0.5);

Comment on lines +443 to +448
const prerelease = semver.prerelease(version);
if (version.includes('nightly')) {
return 'https://nodejs.org/download/nightly';
} else if (prerelease) {
return 'https://nodejs.org/download/rc';
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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';
}

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.

Comment on lines +99 to +105
if (initialUrl.endsWith('/rc')) {
return <im.INodeVersion>nodeTestDistRc;
} else if (initialUrl.endsWith('/nightly')) {
return <im.INodeVersion>nodeTestDistNightly;
} else {
return <im.INodeVersion>nodeTestDist;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants