mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-06 22:18:17 -05:00
fix(plugin-commands-script-runner): run --stream should prefix with dir name (#4703)
close #4702
This commit is contained in:
6
.changeset/sour-peas-prove.md
Normal file
6
.changeset/sour-peas-prove.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-script-runners": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
fix(plugin-commands-script-runner): run --stream should prefix with dir name
|
||||
@@ -19,6 +19,7 @@ export type RecursiveRunOpts = Pick<Config,
|
||||
| 'scriptsPrependNodePath'
|
||||
| 'scriptShell'
|
||||
| 'shellEmulator'
|
||||
| 'stream'
|
||||
> & Required<Pick<Config, 'allProjects' | 'selectedProjectsGraph' | 'workspaceDir'>> &
|
||||
Partial<Pick<Config, 'extraBinPaths' | 'bail' | 'reverse' | 'sort' | 'workspaceConcurrency'>> &
|
||||
{
|
||||
@@ -46,12 +47,12 @@ export default async (
|
||||
} as RecursiveSummary
|
||||
|
||||
const limitRun = pLimit(opts.workspaceConcurrency ?? 4)
|
||||
const stdio = (
|
||||
opts.workspaceConcurrency === 1 ||
|
||||
packageChunks.length === 1 && packageChunks[0].length === 1
|
||||
)
|
||||
? 'inherit'
|
||||
: 'pipe'
|
||||
const stdio =
|
||||
!opts.stream &&
|
||||
(opts.workspaceConcurrency === 1 ||
|
||||
(packageChunks.length === 1 && packageChunks[0].length === 1))
|
||||
? 'inherit'
|
||||
: 'pipe'
|
||||
const existsPnp = existsInDir.bind(null, '.pnp.cjs')
|
||||
const workspacePnpPath = opts.workspaceDir && await existsPnp(opts.workspaceDir)
|
||||
|
||||
|
||||
@@ -1559,3 +1559,84 @@ test('directory filtering', async () => {
|
||||
expect(output).toContain('project-2')
|
||||
}
|
||||
})
|
||||
|
||||
test('run --stream should prefix with dir name', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
location: '.',
|
||||
package: {
|
||||
name: 'root',
|
||||
version: '0.0.0',
|
||||
private: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
location: 'packages/alfa',
|
||||
package: {
|
||||
name: 'alfa',
|
||||
version: '1.0.0',
|
||||
scripts: {
|
||||
test: "node -e \"console.log('OK')\"",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
location: 'packages/beta',
|
||||
package: {
|
||||
name: 'beta',
|
||||
version: '1.0.0',
|
||||
scripts: {
|
||||
test: "node -e \"console.log('OK')\"",
|
||||
},
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
process.chdir('..')
|
||||
await writeYamlFile('pnpm-workspace.yaml', { packages: ['**', '!store/**'] })
|
||||
|
||||
const result = execPnpmSync([
|
||||
'--stream',
|
||||
'--filter',
|
||||
'alfa',
|
||||
'--filter',
|
||||
'beta',
|
||||
'run',
|
||||
'test',
|
||||
])
|
||||
expect(
|
||||
result.stdout
|
||||
.toString()
|
||||
.trim()
|
||||
.split('\n')
|
||||
.sort()
|
||||
.join('\n')
|
||||
).toBe(
|
||||
`Scope: 2 of 3 workspace projects
|
||||
packages/alfa test$ node -e "console.log('OK')"
|
||||
packages/alfa test: Done
|
||||
packages/alfa test: OK
|
||||
packages/beta test$ node -e "console.log('OK')"
|
||||
packages/beta test: Done
|
||||
packages/beta test: OK`
|
||||
)
|
||||
const singleResult = execPnpmSync([
|
||||
'--stream',
|
||||
'--filter',
|
||||
'alfa',
|
||||
'run',
|
||||
'test',
|
||||
])
|
||||
expect(
|
||||
singleResult.stdout
|
||||
.toString()
|
||||
.trim()
|
||||
.split('\n')
|
||||
.sort()
|
||||
.join('\n')
|
||||
).toBe(
|
||||
`packages/alfa test$ node -e "console.log('OK')"
|
||||
packages/alfa test: Done
|
||||
packages/alfa test: OK`
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user