Files
pnpm/env/node.resolver/src/getNodeMirror.ts
2025-07-19 15:11:40 +02:00

13 lines
571 B
TypeScript

import { type Config } from '@pnpm/config'
export function getNodeMirror (rawConfig: Config['rawConfig'], releaseChannel: string): string {
// This is a dynamic lookup since the 'use-node-version' option is allowed to be '<releaseChannel>/<version>'
const configKey = `node-mirror:${releaseChannel}`
const nodeMirror = rawConfig[configKey] ?? `https://nodejs.org/download/${releaseChannel}/`
return normalizeNodeMirror(nodeMirror)
}
function normalizeNodeMirror (nodeMirror: string): string {
return nodeMirror.endsWith('/') ? nodeMirror : `${nodeMirror}/`
}