Skip to content

Commit 5b44aa8

Browse files
committed
download: fix nvm instructions (#7434)
1 parent 1e140cb commit 5b44aa8

File tree

9 files changed

+34
-15
lines changed

9 files changed

+34
-15
lines changed

apps/site/next-data/downloadSnippets.ts

Lines changed: 11 additions & 11 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 3 additions & 0 deletions
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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Télécharger et installer nvm :
22
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
33

4+
# au lieu de redémarrer le shell
5+
\. "$HOME/.nvm/nvm.sh"
6+
47
# Télécharger et installer Node.js :
58
nvm install ${props.release.major}
69

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Unduh dan pasang nvm:
22
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
33

4+
# sebagai pengganti memulai ulang shell
5+
\. "$HOME/.nvm/nvm.sh"
6+
47
# Unduh dan pasang Node.js:
58
nvm install ${props.release.major}
69

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# nvmをダウンロードしてインストールする:
22
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
33

4+
# シェルを再起動する代わりに
5+
\. "$HOME/.nvm/nvm.sh"
6+
47
# Node.jsをダウンロードしてインストールする:
58
nvm install ${props.release.major}
69

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# nvm 다운로드 및 설치:
22
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
33

4+
# 쉘을 다시 시작하는 대신
5+
\. "$HOME/.nvm/nvm.sh"
6+
47
# Node.js 다운로드 및 설치:
58
nvm install ${props.release.major}
69

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Завантажує й установлює nvm:
22
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
33

4+
# замість перезапуску оболонки
5+
\. "$HOME/.nvm/nvm.sh"
6+
47
# Завантажує й установлює Node.js:
58
nvm install ${props.release.major}
69

apps/site/snippets/zh-tw/download/nvm.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# 下載並安裝 nvm:
22
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
33

4+
# 代替重新啟動 shell
5+
\. "$HOME/.nvm/nvm.sh"
6+
47
# 下載並安裝 Node.js:
58
nvm install ${props.release.major}
69

0 commit comments

Comments
 (0)