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) { ...@@ -99,7 +99,10 @@ function getPackageVersion(packageName: string) {
function getBinaryVersion(binaryName: string) { function getBinaryVersion(binaryName: string) {
try { try {
return childProcess.execSync(`${binaryName} --version`).toString().trim() return childProcess
.execFileSync(binaryName, ['--version'])
.toString()
.trim()
} catch { } catch {
return 'N/A' return 'N/A'
} }
......
...@@ -489,7 +489,9 @@ describe('CLI Usage', () => { ...@@ -489,7 +489,9 @@ describe('CLI Usage', () => {
test('should print output', async () => { test('should print output', async () => {
const info = await runNextCommand(['info'], { const info = await runNextCommand(['info'], {
stdout: true, stdout: true,
stderr: true,
}) })
expect(info.stderr || '').toBe('')
expect(info.stdout).toMatch( expect(info.stdout).toMatch(
new RegExp(` new RegExp(`
Operating System: 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