mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-25 15:07:06 -04:00
6
.changeset/odd-garlics-laugh.md
Normal file
6
.changeset/odd-garlics-laugh.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-env": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
`pnpm env use` should download the right Node.js tarball on Raspberry Pi [#4007](https://github.com/pnpm/pnpm/issues/4007).
|
||||
@@ -11,6 +11,7 @@ import renameOverwrite from 'rename-overwrite'
|
||||
import tempy from 'tempy'
|
||||
import loadJsonFile from 'load-json-file'
|
||||
import writeJsonFile from 'write-json-file'
|
||||
import normalizeArch from './normalizeArch'
|
||||
|
||||
export type NvmNodeCommandOptions = Pick<Config,
|
||||
| 'bin'
|
||||
@@ -116,7 +117,7 @@ async function downloadAndUnpackZip (
|
||||
|
||||
function getNodeJSTarball (nodeVersion: string, releaseDir: string) {
|
||||
const platform = process.platform === 'win32' ? 'win' : process.platform
|
||||
const arch = platform === 'win' && process.arch === 'ia32' ? 'x86' : process.arch
|
||||
const arch = normalizeArch(process.platform, process.arch)
|
||||
const extension = platform === 'win' ? 'zip' : 'tar.gz'
|
||||
const pkgName = `node-v${nodeVersion}-${platform}-${arch}`
|
||||
return {
|
||||
|
||||
9
packages/plugin-commands-env/src/normalizeArch.ts
Normal file
9
packages/plugin-commands-env/src/normalizeArch.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default function getNormalizedArch (platform: string, arch: string) {
|
||||
if (platform === 'win32' && arch === 'ia32') {
|
||||
return 'x86'
|
||||
}
|
||||
if (arch === 'arm') {
|
||||
return 'armv7l'
|
||||
}
|
||||
return arch
|
||||
}
|
||||
9
packages/plugin-commands-env/test/normalizeArch.test.ts
Normal file
9
packages/plugin-commands-env/test/normalizeArch.test.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import normalizeArch from '@pnpm/plugin-commands-env/lib/normalizeArch'
|
||||
|
||||
test.each([
|
||||
['win32', 'ia32', 'x86'],
|
||||
['linux', 'arm', 'armv7l'], // Raspberry Pi 4
|
||||
['linux', 'x64', 'x64'],
|
||||
])('normalizedArch(%s, %s)', (platform, arch, normalizedArch) => {
|
||||
expect(normalizeArch(platform, arch)).toBe(normalizedArch)
|
||||
})
|
||||
Reference in New Issue
Block a user