Unverified Commit ef7b5352 authored by Steven's avatar Steven Committed by GitHub

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.
parent 59905c10
......@@ -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'
}
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment