fix: pnpm exec should specify command (#8774)

This commit is contained in:
btea authored and GitHub committed 2024-11-17 17:07:32 +01:00
1 parent 2f210d9d58
commit ef7c10221c
3 files changed
+23

No files matched your search

+5
View 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")
})