Skip to content

Commit a55d025

Browse files
committed
download: fix nvm instructions (#7434)
1 parent 31f7b03 commit a55d025

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

apps/site/next-data/downloadSnippets.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import {
88
import { availableLocaleCodes } from '@/next.locales.mjs';
99
import type { DownloadSnippet } from '@/types';
1010

11-
const getDownloadSnippets = (lang: string): Promise<Array<DownloadSnippet>> => {
11+
export default async function getDownloadSnippets(
12+
lang: string
13+
): Promise<Array<DownloadSnippet>> {
1214
// Prevents attempting to retrieve data for an unsupported language as both the generator
1315
// and the API endpoint will simply return 404. And we want to prevent a 404 response.
14-
if (availableLocaleCodes.includes(lang) === false) {
15-
return Promise.resolve([]);
16+
if (!availableLocaleCodes.includes(lang)) {
17+
return [];
1618
}
1719

1820
const IS_NOT_VERCEL_RUNTIME_ENV =
@@ -24,9 +26,10 @@ const getDownloadSnippets = (lang: string): Promise<Array<DownloadSnippet>> => {
2426
// the data directly within the current thread, which will anyways be loaded only once
2527
// We use lazy-imports to prevent `provideBlogData` from executing on import
2628
if (ENABLE_STATIC_EXPORT || IS_NOT_VERCEL_RUNTIME_ENV) {
27-
return import('@/next-data/providers/downloadSnippets').then(
28-
({ default: provideDownloadSnippets }) => provideDownloadSnippets(lang)!
29+
const { default: provideDownloadSnippets } = await import(
30+
'@/next-data/providers/downloadSnippets'
2931
);
32+
return provideDownloadSnippets(lang)!;
3033
}
3134

3235
// Applies the language to the URL, since this content is actually localized
@@ -41,9 +44,6 @@ const getDownloadSnippets = (lang: string): Promise<Array<DownloadSnippet>> => {
4144
// outdated information being shown to the user.
4245
// Note: We do manual JSON.parse after response.text() to prevent React from throwing an Error
4346
// that does not provide a clear stack trace of which request is failing and what the JSON.parse error is
44-
return fetch(fetchURL)
45-
.then(response => response.text())
46-
.then(JSON.parse);
47-
};
48-
49-
export default getDownloadSnippets;
47+
const response = await fetch(fetchURL);
48+
return JSON.parse(await response.text());
49+
}

apps/site/next-data/generators/downloadSnippets.mjs

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { availableLocaleCodes } from '../../next.locales.mjs';
1111
* This method is used to generate the Node.js Website Download Snippets
1212
* for self-consumption during RSC and Static Builds
1313
*/
14-
const generateDownloadSnippets = async () => {
14+
export default async function generateDownloadSnippets() {
1515
/**
1616
* This generates all the Download Snippets for each available Locale
1717
*
@@ -39,6 +39,4 @@ const generateDownloadSnippets = async () => {
3939
});
4040

4141
return new Map(await Promise.all(downloadSnippets));
42-
};
43-
44-
export default generateDownloadSnippets;
42+
}

apps/site/snippets/en/download/nvm.bash

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Download and install nvm:
22
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
33

4+
# in lieu of restarting the shell
5+
\. "$HOME/.nvm/nvm.sh"
6+
47
# Download and install Node.js:
58
nvm install ${props.release.major}
69

0 commit comments

Comments
 (0)