mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-06 08:18:16 -05:00
fix: don't list commands twice in workspace root (#3423)
This commit is contained in:
5
.changeset/metal-clocks-learn.md
Normal file
5
.changeset/metal-clocks-learn.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-script-runners": patch
|
||||
---
|
||||
|
||||
Don't list the commands twice when `pnpm run` is executed in the root of a workspace.
|
||||
@@ -136,7 +136,9 @@ export async function handler (
|
||||
}
|
||||
const manifest = await readProjectManifestOnly(dir, opts)
|
||||
if (!scriptName) {
|
||||
const rootManifest = opts.workspaceDir ? (await tryReadProjectManifest(opts.workspaceDir, opts)).manifest : undefined
|
||||
const rootManifest = opts.workspaceDir && opts.workspaceDir !== dir
|
||||
? (await tryReadProjectManifest(opts.workspaceDir, opts)).manifest
|
||||
: undefined
|
||||
return printProjectCommands(manifest, rootManifest ?? undefined)
|
||||
}
|
||||
if (scriptName !== 'start' && !manifest.scripts?.[scriptName]) {
|
||||
|
||||
@@ -295,17 +295,18 @@ test('"pnpm run" prints the list of available commands, including commands of th
|
||||
|
||||
const { allProjects, selectedProjectsGraph } = await readProjects(process.cwd(), [])
|
||||
|
||||
process.chdir('foo')
|
||||
const output = await run.handler({
|
||||
allProjects,
|
||||
dir: process.cwd(),
|
||||
extraBinPaths: [],
|
||||
rawConfig: {},
|
||||
selectedProjectsGraph,
|
||||
workspaceDir,
|
||||
}, [])
|
||||
{
|
||||
process.chdir('foo')
|
||||
const output = await run.handler({
|
||||
allProjects,
|
||||
dir: process.cwd(),
|
||||
extraBinPaths: [],
|
||||
rawConfig: {},
|
||||
selectedProjectsGraph,
|
||||
workspaceDir,
|
||||
}, [])
|
||||
|
||||
expect(output).toBe(`\
|
||||
expect(output).toBe(`\
|
||||
Lifecycle scripts:
|
||||
test
|
||||
ts-node test
|
||||
@@ -319,6 +320,27 @@ Commands of the root workspace project (to run them, use "pnpm -w run"):
|
||||
echo root
|
||||
test
|
||||
test-all`)
|
||||
}
|
||||
{
|
||||
process.chdir('..')
|
||||
const output = await run.handler({
|
||||
allProjects,
|
||||
dir: process.cwd(),
|
||||
extraBinPaths: [],
|
||||
rawConfig: {},
|
||||
selectedProjectsGraph,
|
||||
workspaceDir,
|
||||
}, [])
|
||||
|
||||
expect(output).toBe(`\
|
||||
Lifecycle scripts:
|
||||
test
|
||||
test-all
|
||||
|
||||
Commands available via "pnpm run":
|
||||
build
|
||||
echo root`)
|
||||
}
|
||||
})
|
||||
|
||||
test('pnpm run does not fail with --if-present even if the wanted script is not present', async () => {
|
||||
|
||||
Reference in New Issue
Block a user