mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-24 02:57:04 -05:00
@@ -108,8 +108,8 @@ export async function parseCliArgs (
|
||||
return 'add'
|
||||
}
|
||||
|
||||
function getEscapeArgsWithSpecialCaseForRun (): string[] | undefined {
|
||||
if (cmd !== 'run') {
|
||||
function getEscapeArgsWithSpecialCases (): string[] | undefined {
|
||||
if (cmd !== 'run' && cmd !== 'dlx') {
|
||||
return opts.escapeArgs
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ export async function parseCliArgs (
|
||||
},
|
||||
inputArgv,
|
||||
0,
|
||||
{ escapeArgs: getEscapeArgsWithSpecialCaseForRun() }
|
||||
{ escapeArgs: getEscapeArgsWithSpecialCases() }
|
||||
)
|
||||
const workspaceDir = await getWorkspaceDir(options)
|
||||
|
||||
|
||||
@@ -336,3 +336,51 @@ test('should not swallows empty string in params', async () => {
|
||||
expect(cmd).toBe('run')
|
||||
expect(params).toStrictEqual(['echo', '', 'foo', '', 'bar'])
|
||||
})
|
||||
|
||||
test('dlx parses CLI options in between "dlx" and the command name', async () => {
|
||||
const { params, options, cmd } = await parseCliArgs({
|
||||
...DEFAULT_OPTS,
|
||||
}, [
|
||||
'--reporter=append-only',
|
||||
'dlx',
|
||||
'--allow-build=some-package',
|
||||
'--package=some-bin-package',
|
||||
'some-command',
|
||||
'--this-is-not-a-flag',
|
||||
'another-argument',
|
||||
])
|
||||
expect(cmd).toBe('dlx')
|
||||
expect(options).toStrictEqual({
|
||||
reporter: 'append-only',
|
||||
'allow-build': 'some-package',
|
||||
package: 'some-bin-package',
|
||||
})
|
||||
expect(params).toStrictEqual([
|
||||
'some-command',
|
||||
'--this-is-not-a-flag',
|
||||
'another-argument',
|
||||
])
|
||||
})
|
||||
|
||||
test('dlx stops parsing after "--"', async () => {
|
||||
const { params, options, cmd } = await parseCliArgs({
|
||||
...DEFAULT_OPTS,
|
||||
}, [
|
||||
'dlx',
|
||||
'--package=some-package',
|
||||
'--allow-build=foo',
|
||||
'--allow-build=bar',
|
||||
'--',
|
||||
'--this-is-a-command',
|
||||
'argument',
|
||||
])
|
||||
expect(cmd).toBe('dlx')
|
||||
expect(options).toStrictEqual({
|
||||
package: 'some-package',
|
||||
'allow-build': ['foo', 'bar'],
|
||||
})
|
||||
expect(params).toStrictEqual([
|
||||
'--this-is-a-command',
|
||||
'argument',
|
||||
])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user