MCPcopy Index your code
hub / github.com/nodejs/nodejs.org / getNodeDownloadUrl

Function getNodeDownloadUrl

apps/site/util/url.ts:35–108  ·  view source on GitHub ↗
({
  versionWithPrefix,
  os = 'LOADING',
  platform = 'x64',
  kind = 'installer',
}: DownloadOptions)

Source from the content-addressed store, hash-verified

33 * Generates a Node.js download URL for the given options
34 */
35export const getNodeDownloadUrl = ({
36 versionWithPrefix,
37 os = 'LOADING',
38 platform = 'x64',
39 kind = 'installer',
40}: DownloadOptions) => {
41 const baseURL = `${DIST_URL}${versionWithPrefix}`;
42
43 if (kind === 'source') {
44 return `${baseURL}/node-${versionWithPrefix}.tar.gz`;
45 }
46
47 if (kind === 'shasum') {
48 return `${baseURL}/SHASUMS256.txt.asc`;
49 }
50
51 switch (os) {
52 case 'MAC':
53 // Prepares a downloadable Node.js installer link for the x64, ARM64 platforms
54 if (kind === 'installer') {
55 return `${baseURL}/node-${versionWithPrefix}.pkg`;
56 }
57
58 // Prepares a downloadable Node.js link for the ARM64 platform
59 if (typeof platform === 'string') {
60 return `${baseURL}/node-${versionWithPrefix}-darwin-${platform}.tar.gz`;
61 }
62
63 // Prepares a downloadable Node.js link for the x64 platform.
64 // Since the x86 platform is not officially supported, returns the x64
65 // link as the default value.
66 return `${baseURL}/node-${versionWithPrefix}-darwin-x64.tar.gz`;
67 case 'WIN': {
68 if (kind === 'installer') {
69 // Prepares a downloadable Node.js installer link for the ARM platforms
70 if (typeof platform === 'string') {
71 return `${baseURL}/node-${versionWithPrefix}-${platform}.msi`;
72 }
73
74 // Prepares a downloadable Node.js installer link for the x64 and x86 platforms
75 return `${baseURL}/node-${versionWithPrefix}-x${platform}.msi`;
76 }
77
78 // Prepares a downloadable Node.js link for the ARM64 platform
79 if (typeof platform === 'string') {
80 return `${baseURL}/node-${versionWithPrefix}-win-${platform}.zip`;
81 }
82
83 // Prepares a downloadable Node.js link for the x64 and x86 platforms
84 return `${baseURL}/node-${versionWithPrefix}-win-x${platform}.zip`;
85 }
86 case 'LINUX':
87 // Prepares a downloadable Node.js link for the ARM platforms such as
88 // ARMv7 and ARMv8
89 if (typeof platform === 'string') {
90 return `${baseURL}/node-${versionWithPrefix}-linux-${platform}.tar.xz`;
91 }
92

Callers 6

DownloadLinkFunction · 0.90
PrebuiltDownloadButtonsFunction · 0.90
DownloadButtonFunction · 0.90
url.test.mjsFile · 0.90
createDownloadArtifactFunction · 0.90
buildReleaseArtifactsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected