fix: dlx should ignore settings from package.json (#9179)

close #9178
close #9174
This commit is contained in:
Zoltan Kochan
2025-02-26 12:55:17 +01:00
committed by GitHub
parent 69f922a750
commit 0b31bf00d8
2 changed files with 27 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-script-runners": patch
"pnpm": patch
---
`pnpm dlx` should ignore settings from the `package.json` file in the current working directory [#9178](https://github.com/pnpm/pnpm/issues/9178).

View File

@@ -12,6 +12,7 @@ import { add } from '@pnpm/plugin-commands-installation'
import { readPackageJsonFromDir } from '@pnpm/read-package-json'
import { getBinsFromPackageManifest } from '@pnpm/package-bins'
import { pickRegistryForPackage } from '@pnpm/pick-registry-for-package'
import { type PnpmSettings } from '@pnpm/types'
import execa from 'execa'
import omit from 'ramda/src/omit'
import pick from 'ramda/src/pick'
@@ -75,7 +76,7 @@ export type DlxCommandOptions = {
package?: string[]
shellMode?: boolean
allowBuild?: string[]
} & Pick<Config, 'extraBinPaths' | 'registries' | 'reporter' | 'userAgent' | 'cacheDir' | 'dlxCacheMaxAge' | 'useNodeVersion' | 'symlink'> & add.AddCommandOptions
} & Pick<Config, 'extraBinPaths' | 'registries' | 'reporter' | 'userAgent' | 'cacheDir' | 'dlxCacheMaxAge' | 'useNodeVersion' | 'symlink'> & add.AddCommandOptions & PnpmSettings
export async function handler (
opts: DlxCommandOptions,
@@ -110,7 +111,25 @@ export async function handler (
await add.handler({
// Ideally the config reader should ignore these settings when the dlx command is executed.
// This is a temporary solution until "@pnpm/config" is refactored.
...omit(['workspaceDir', 'rootProjectManifest', 'symlink'], opts),
...omit([
'workspaceDir',
'rootProjectManifest',
'symlink',
// Options from root manifest
'allowNonAppliedPatches',
'allowedDeprecatedVersions',
'configDependencies',
'ignoredBuiltDependencies',
'ignoredOptionalDependencies',
'neverBuiltDependencies',
'onlyBuiltDependencies',
'onlyBuiltDependenciesFile',
'overrides',
'packageExtensions',
'patchedDependencies',
'peerDependencyRules',
'supportedArchitectures',
], opts),
bin: path.join(cachedDir, 'node_modules/.bin'),
dir: cachedDir,
lockfileDir: cachedDir,