mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-06 22:18:17 -05:00
feat: allow installing mutiple packages using dlx command (#3710)
Allow use of mutiple --package parameters with pnpm dlx command Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
5
.changeset/seven-birds-flash.md
Normal file
5
.changeset/seven-birds-flash.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-script-runners": minor
|
||||
---
|
||||
|
||||
Support for multiple `--package` parameters added for `pnpm dlx` command
|
||||
@@ -13,7 +13,7 @@ export function rcOptionsTypes () {
|
||||
}
|
||||
|
||||
export const cliOptionsTypes = () => ({
|
||||
package: String,
|
||||
package: [String, Array],
|
||||
})
|
||||
|
||||
export function help () {
|
||||
@@ -37,7 +37,7 @@ export function help () {
|
||||
|
||||
export async function handler (
|
||||
opts: {
|
||||
package?: string
|
||||
package?: string[]
|
||||
},
|
||||
params: string[]
|
||||
) {
|
||||
@@ -55,8 +55,8 @@ export async function handler (
|
||||
} catch (err) { }
|
||||
})
|
||||
await rimraf(bins)
|
||||
const pkg = opts.package ?? params[0]
|
||||
await execa('pnpm', ['add', pkg, '--global', '--global-dir', prefix, '--dir', prefix], {
|
||||
const pkgs = opts.package ?? params.slice(0, 1)
|
||||
await execa('pnpm', ['add', ...pkgs, '--global', '--global-dir', prefix, '--dir', prefix], {
|
||||
stdio: 'inherit',
|
||||
})
|
||||
await execa(params[0], params.slice(1), {
|
||||
|
||||
@@ -10,11 +10,14 @@ test('dlx', async () => {
|
||||
expect(fs.existsSync('foo')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('dlx --package <pkg>', async () => {
|
||||
test('dlx --package <pkg1> [--package <pkg2>]', async () => {
|
||||
prepareEmpty()
|
||||
|
||||
await dlx.handler({
|
||||
package: 'zkochan/for-testing-pnpm-dlx',
|
||||
package: [
|
||||
'zkochan/for-testing-pnpm-dlx',
|
||||
'is-positive',
|
||||
],
|
||||
}, ['foo'])
|
||||
|
||||
expect(fs.existsSync('foo')).toBeTruthy()
|
||||
|
||||
Reference in New Issue
Block a user