Skip to content

Commit

Permalink
fix: correctly detect the active Node.js version
Browse files Browse the repository at this point in the history
ref #4203
  • Loading branch information
zkochan committed May 23, 2022
1 parent 24f936b commit 9f74542
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-phones-sing.md
@@ -0,0 +1,5 @@
---
"@pnpm/config": patch
---

Do not return a default value for the node-version setting.
5 changes: 5 additions & 0 deletions .changeset/thin-chefs-sing.md
@@ -0,0 +1,5 @@
---
"pnpm": patch
---

Correctly detect the active Node.js version, when the pnpm CLI is bundled to an executable [#4203](https://github.com/pnpm/pnpm/issues/4203).
2 changes: 1 addition & 1 deletion packages/config/package.json
Expand Up @@ -32,12 +32,12 @@
},
"homepage": "https://github.com/pnpm/pnpm/blob/main/packages/config#readme",
"dependencies": {
"@pnpm/npm-conf": "1.0.1",
"@pnpm/constants": "workspace:6.1.0",
"@pnpm/error": "workspace:3.0.1",
"@pnpm/pnpmfile": "workspace:2.0.2",
"@pnpm/read-project-manifest": "workspace:3.0.2",
"@pnpm/types": "workspace:8.0.1",
"@zkochan/npm-conf": "2.0.2",
"camelcase": "^6.2.0",
"can-write-to-dir": "^1.1.1",
"is-subdir": "^1.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/config/src/index.ts
Expand Up @@ -2,11 +2,11 @@ import path from 'path'
import fs from 'fs'
import { LAYOUT_VERSION } from '@pnpm/constants'
import PnpmError from '@pnpm/error'
import loadNpmConf from '@pnpm/npm-conf'
import npmTypes from '@pnpm/npm-conf/lib/types'
import { requireHooks } from '@pnpm/pnpmfile'
import { safeReadProjectManifestOnly } from '@pnpm/read-project-manifest'
import camelcase from 'camelcase'
import loadNpmConf from '@zkochan/npm-conf'
import npmTypes from '@zkochan/npm-conf/lib/types'
import normalizeRegistryUrl from 'normalize-registry-url'
import fromPairs from 'ramda/src/fromPairs'
import realpathMissing from 'realpath-missing'
Expand Down
4 changes: 2 additions & 2 deletions packages/config/test/globalBinDir.test.ts
Expand Up @@ -10,8 +10,8 @@ import getConfig from '@pnpm/config'
const globalBinDir = path.join(homedir(), '.local', 'pnpm')
const isWindows = process.platform === 'win32'

jest.mock('@zkochan/npm-conf/lib/conf', () => {
const originalModule = jest.requireActual('@zkochan/npm-conf/lib/conf')
jest.mock('@pnpm/npm-conf/lib/conf', () => {
const originalModule = jest.requireActual('@pnpm/npm-conf/lib/conf')
class MockedConf extends originalModule {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor (base: any, types: any) {
Expand Down
5 changes: 4 additions & 1 deletion packages/config/test/index.ts
Expand Up @@ -4,8 +4,8 @@ import path from 'path'
import PATH from 'path-name'
import getConfig from '@pnpm/config'
import PnpmError from '@pnpm/error'
import loadNpmConf from '@pnpm/npm-conf'
import prepare, { prepareEmpty } from '@pnpm/prepare'
import loadNpmConf from '@zkochan/npm-conf'

import symlinkDir from 'symlink-dir'

Expand Down Expand Up @@ -36,6 +36,9 @@ test('getConfig()', async () => {
expect(config.fetchRetryFactor).toEqual(10)
expect(config.fetchRetryMintimeout).toEqual(10000)
expect(config.fetchRetryMaxtimeout).toEqual(60000)
// nodeVersion should not have a default value.
// When not specified, the package-is-installable package detects nodeVersion automatically.
expect(config.nodeVersion).toBeUndefined()
})

test('throw error if --link-workspace-packages is used with --global', async () => {
Expand Down
12 changes: 10 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typings/local.d.ts
Expand Up @@ -23,12 +23,12 @@ declare module '@zkochan/libnpx/index' {
export = anything;
}

declare module '@zkochan/npm-conf' {
declare module '@pnpm/npm-conf' {
const anything: any;
export = anything;
}

declare module '@zkochan/npm-conf/lib/types' {
declare module '@pnpm/npm-conf/lib/types' {
const anything: any;
export = anything;
}
Expand Down

0 comments on commit 9f74542

Please sign in to comment.