-
-
Couldn't load subscription status.
- Fork 6.4k
fix: fallback to Maintenance LTS if no Active LTS found #8251
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,12 +19,18 @@ const WithNodeRelease: FC<WithNodeReleaseProps> = async ({ | |
| }) => { | ||
| const releaseData = await provideReleaseData(); | ||
|
|
||
| const matchingRelease = releaseData.find(release => | ||
| [status].flat().includes(release.status) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original code would have worked fine, there was no need to refactor this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No? If there was a Maintenance LTS release in the array before an Active LTS release, the old logic would have picked the Maintenance LTS release. The new logic ensures we've looked at the whole array for an Active LTS release before switching to a Maintenance LTS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, that was an oversight. But I'd still wage over not using for statements within a React component. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the context of this fix, I'd prefer for robust logic over using newer language syntax, a for loop works perfectly fine and really is doing nothing fundamentally different. |
||
| ); | ||
| let matchingRelease: NodeRelease | undefined; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could we do a folllo-up PR that doesn't do for and uses proper built-ins to match the repo convention style? cc @nodejs/nodejs-website There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure there is a built-in that can do what this is doing? No array methods have a break equivalent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean what we were doing before, Using array.find() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No? The old logic was iterating over release data so you can do a find to early return a match from it. The new logic iterates over status but early returns a value from release data, which I don't believe can be done cleanly with array methods? |
||
| for (const statusItem of Array.isArray(status) ? status : [status]) { | ||
| matchingRelease = releaseData.find( | ||
| release => release.status === statusItem | ||
| ); | ||
| if (matchingRelease) { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (matchingRelease !== undefined) { | ||
| return <Component release={matchingRelease!} />; | ||
| if (matchingRelease) { | ||
| return <Component release={matchingRelease} />; | ||
| } | ||
|
|
||
| return null; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.