feat(exec): default reporterHidePrefix to true (#8176)

close #8174
This commit is contained in:
Khải
2024-06-06 16:19:14 +07:00
committed by GitHub
parent 1e5985a937
commit 271386f0a0
3 changed files with 45 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-script-runners": patch
"pnpm": patch
---
Set `reporter-hide-prefix` to `true` by default for `pnpm exec`. In order to show prefix, the user now has to explicitly set `reporter-hide-prefix=false` [#8174](https://github.com/pnpm/pnpm/issues/8174).

View File

@@ -186,7 +186,7 @@ export async function handler (
'./node_modules/.bin',
...opts.extraBinPaths,
]
const reporterShowPrefix = opts.recursive && !opts.reporterHidePrefix
const reporterShowPrefix = opts.recursive && opts.reporterHidePrefix === false
for (const chunk of chunks) {
// eslint-disable-next-line no-await-in-loop
await Promise.all(chunk.map(async (prefix: string) =>

View File

@@ -21,7 +21,7 @@ afterEach(() => {
(lifecycleLogger.debug as jest.Mock).mockClear()
})
test('pnpm exec --recursive prints prefixes', async () => {
test('pnpm exec --recursive --no-reporter-hide-prefix prints prefixes', async () => {
preparePackages([
{
location: 'packages/foo',
@@ -51,6 +51,7 @@ test('pnpm exec --recursive prints prefixes', async () => {
dir: process.cwd(),
recursive: true,
bail: true,
reporterHidePrefix: false,
selectedProjectsGraph,
}, [process.execPath, scriptFile])
@@ -119,3 +120,39 @@ test('pnpm exec --recursive --reporter-hide-prefix does not print prefixes', asy
expect(lifecycleLogger.debug).not.toHaveBeenCalled()
})
test('pnpm exec --recursive does not print prefixes by default', async () => {
preparePackages([
{
location: 'packages/foo',
package: { name: 'foo' },
},
{
location: 'packages/bar',
package: { name: 'bar' },
},
])
await writeYamlFile('pnpm-workspace.yaml', {
packages: ['packages/*'],
})
const { selectedProjectsGraph } = await readProjects(process.cwd(), [])
const scriptFile = path.resolve('script.js')
fs.writeFileSync(scriptFile, `
console.log('hello from stdout')
console.error('hello from stderr')
console.log('name is ' + require(require('path').resolve('package.json')).name)
`)
await exec.handler({
...DEFAULT_OPTS,
dir: process.cwd(),
recursive: true,
bail: true,
selectedProjectsGraph,
}, [process.execPath, scriptFile])
expect(lifecycleLogger.debug).not.toHaveBeenCalled()
})