mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-11 00:18:32 -05:00
fix: pnpm exec should specify command (#8774)
This commit is contained in:
5
.changeset/brown-weeks-roll.md
Normal file
5
.changeset/brown-weeks-roll.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-script-runners": patch
|
||||
---
|
||||
|
||||
`pnpm exec` should print a meaningful error message when no command is provided [#8752](https://github.com/pnpm/pnpm/issues/8752).
|
||||
@@ -174,6 +174,9 @@ export async function handler (
|
||||
if (params[0] === '--') {
|
||||
params.shift()
|
||||
}
|
||||
if (!params[0]) {
|
||||
throw new PnpmError('EXEC_MISSING_COMMAND', '\'pnpm exec\' requires a command to run')
|
||||
}
|
||||
const limitRun = pLimit(opts.workspaceConcurrency ?? 4)
|
||||
|
||||
if (opts.verifyDepsBeforeRun && !process.env[SKIP_ENV_KEY]) {
|
||||
@@ -205,6 +208,10 @@ export async function handler (
|
||||
}
|
||||
}
|
||||
|
||||
if (!opts.selectedProjectsGraph) {
|
||||
throw new PnpmError('RECURSIVE_EXEC_NO_PACKAGE', 'No package found in this workspace')
|
||||
}
|
||||
|
||||
if (opts.resumeFrom) {
|
||||
chunks = getResumedPackageChunks({
|
||||
resumeFrom: opts.resumeFrom,
|
||||
|
||||
@@ -41,3 +41,14 @@ test('exec should set the NODE_OPTIONS env var', async () => {
|
||||
}),
|
||||
}))
|
||||
})
|
||||
|
||||
test('exec should specify the command', async () => {
|
||||
prepareEmpty()
|
||||
|
||||
await expect(exec.handler({
|
||||
...DEFAULT_OPTS,
|
||||
dir: process.cwd(),
|
||||
selectedProjectsGraph: {},
|
||||
}, [])
|
||||
).rejects.toThrow("'pnpm exec' requires a command to run")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user