Skip to content

Commit

Permalink
download: fix nvm instructions (#7434)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Feb 3, 2025
1 parent 1e140cb commit 5b44aa8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 15 deletions.
22 changes: 11 additions & 11 deletions apps/site/next-data/downloadSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import {
import { availableLocaleCodes } from '@/next.locales.mjs';
import type { DownloadSnippet } from '@/types';

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

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

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

export default getDownloadSnippets;
const response = await fetch(fetchURL);
return JSON.parse(await response.text());
}
6 changes: 2 additions & 4 deletions apps/site/next-data/generators/downloadSnippets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { availableLocaleCodes } from '../../next.locales.mjs';
* This method is used to generate the Node.js Website Download Snippets
* for self-consumption during RSC and Static Builds
*/
const generateDownloadSnippets = async () => {
export default async function generateDownloadSnippets() {
/**
* This generates all the Download Snippets for each available Locale
*
Expand Down Expand Up @@ -39,6 +39,4 @@ const generateDownloadSnippets = async () => {
});

return new Map(await Promise.all(downloadSnippets));
};

export default generateDownloadSnippets;
}
3 changes: 3 additions & 0 deletions apps/site/snippets/en/download/nvm.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"

# Download and install Node.js:
nvm install ${props.release.major}

Expand Down
3 changes: 3 additions & 0 deletions apps/site/snippets/fr/download/nvm.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Télécharger et installer nvm :
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# au lieu de redémarrer le shell
\. "$HOME/.nvm/nvm.sh"

# Télécharger et installer Node.js :
nvm install ${props.release.major}

Expand Down
3 changes: 3 additions & 0 deletions apps/site/snippets/id/download/nvm.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Unduh dan pasang nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# sebagai pengganti memulai ulang shell
\. "$HOME/.nvm/nvm.sh"

# Unduh dan pasang Node.js:
nvm install ${props.release.major}

Expand Down
3 changes: 3 additions & 0 deletions apps/site/snippets/ja/download/nvm.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# nvmをダウンロードしてインストールする:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# シェルを再起動する代わりに
\. "$HOME/.nvm/nvm.sh"

# Node.jsをダウンロードしてインストールする:
nvm install ${props.release.major}

Expand Down
3 changes: 3 additions & 0 deletions apps/site/snippets/ko/download/nvm.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# nvm 다운로드 및 설치:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# 쉘을 다시 시작하는 대신
\. "$HOME/.nvm/nvm.sh"

# Node.js 다운로드 및 설치:
nvm install ${props.release.major}

Expand Down
3 changes: 3 additions & 0 deletions apps/site/snippets/uk/download/nvm.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Завантажує й установлює nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# замість перезапуску оболонки
\. "$HOME/.nvm/nvm.sh"

# Завантажує й установлює Node.js:
nvm install ${props.release.major}

Expand Down
3 changes: 3 additions & 0 deletions apps/site/snippets/zh-tw/download/nvm.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# 下載並安裝 nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# 代替重新啟動 shell
\. "$HOME/.nvm/nvm.sh"

# 下載並安裝 Node.js:
nvm install ${props.release.major}

Expand Down

0 comments on commit 5b44aa8

Please sign in to comment.