Skip to content

Commit ef7b535

Browse files
authored
Fix next info accidentally printing stderr (#35556)
I noticed a few issues that had "Output from `next info`" with the first line as ``` /bin/sh: pnpm: command not found ``` This was because `execSync()` was still printing to stderr when a command was not found. Changing to `execFileSync()` fixed it so we no longer print to stderr when a command is not found.
1 parent 59905c1 commit ef7b535

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/next/cli/next-info.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ function getPackageVersion(packageName: string) {
9999

100100
function getBinaryVersion(binaryName: string) {
101101
try {
102-
return childProcess.execSync(`${binaryName} --version`).toString().trim()
102+
return childProcess
103+
.execFileSync(binaryName, ['--version'])
104+
.toString()
105+
.trim()
103106
} catch {
104107
return 'N/A'
105108
}

test/integration/cli/test/index.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ describe('CLI Usage', () => {
489489
test('should print output', async () => {
490490
const info = await runNextCommand(['info'], {
491491
stdout: true,
492+
stderr: true,
492493
})
494+
expect(info.stderr || '').toBe('')
493495
expect(info.stdout).toMatch(
494496
new RegExp(`
495497
Operating System:

0 commit comments

Comments
 (0)