Skip to content

Commit

Permalink
Fix next info accidentally printing stderr (#35556)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
styfle committed Mar 23, 2022
1 parent 59905c1 commit ef7b535
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/next/cli/next-info.ts
Expand Up @@ -99,7 +99,10 @@ function getPackageVersion(packageName: string) {

function getBinaryVersion(binaryName: string) {
try {
return childProcess.execSync(`${binaryName} --version`).toString().trim()
return childProcess
.execFileSync(binaryName, ['--version'])
.toString()
.trim()
} catch {
return 'N/A'
}
Expand Down
2 changes: 2 additions & 0 deletions test/integration/cli/test/index.test.js
Expand Up @@ -489,7 +489,9 @@ describe('CLI Usage', () => {
test('should print output', async () => {
const info = await runNextCommand(['info'], {
stdout: true,
stderr: true,
})
expect(info.stderr || '').toBe('')
expect(info.stdout).toMatch(
new RegExp(`
Operating System:
Expand Down

0 comments on commit ef7b535

Please sign in to comment.