fix: dlx should work without a configured global directory (#4612)

* fix: dlx should work without a configured global directory

close #4597

* docs: add changesets
This commit is contained in:
Zoltan Kochan authored and GitHub committed 2022-04-24 13:02:32 +03:00
1 parent 17fa76e2bb
commit c5caf83346
4 files changed
+22 -2

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-script-runners": patch
---
`pnpm dlx` should work without a configure global directory.
+5
View File
@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-installation": patch
---
Allow to pass `global-bin-dir` through CLI options to the `add` command.
@@ -18,6 +18,7 @@ export function rcOptionsTypes () {
'fetch-retry-mintimeout',
'fetch-timeout',
'force',
'global-bin-dir',
'global-dir',
'global-pnpmfile',
'global',
@@ -61,15 +61,24 @@ export async function handler (
})
await rimraf(bins)
const pkgs = opts.package ?? params.slice(0, 1)
const pnpmArgs = ['add', ...pkgs, '--global', '--global-dir', prefix, '--dir', prefix]
const pnpmArgs = [
'add',
...pkgs,
'--global',
`--global-dir=${prefix}`,
`--dir=${prefix}`,
`--config.global-bin-dir=${bins}`,
]
if (opts.reporter) {
pnpmArgs.push(`--reporter=${opts.reporter}`)
}
const env = makeEnv({ userAgent: opts.userAgent, prependPaths: [bins] })
await execa('pnpm', pnpmArgs, {
env,
stdio: 'inherit',
})
await execa(versionless(scopeless(params[0])), params.slice(1), {
env: makeEnv({ userAgent: opts.userAgent, prependPaths: [bins] }),
env,
stdio: 'inherit',
})
}