[test] Use execFileSync() to get processes (#9445)

`spawnSync()` does not throw if the command can't be found in the PATH or if an error occurs. If we use `execFileSync()`, it will throw and that was likely the desired behavior in this test utility function.
This commit is contained in:
Chris Barber
2023-02-14 16:59:52 -06:00
committed by GitHub
parent 881e43a0e2
commit bb9faaed99

View File

@@ -10,7 +10,7 @@ const { version: cliVersion } = require('../../package.json');
const {
fetchCachedToken,
} = require('../../../../test/lib/deployment/now-deploy');
const { spawnSync } = require('child_process');
const { spawnSync, execFileSync } = require('child_process');
jest.setTimeout(6 * 60 * 1000);
@@ -522,7 +522,7 @@ async function ps(parentPid, pids = {}) {
: ['ps', '-o', 'pid', '--no-headers', '--ppid', parentPid];
try {
const { stdout: buf } = spawnSync(cmd[0], cmd.slice(1), {
const buf = execFileSync(cmd[0], cmd.slice(1), {
encoding: 'utf-8',
});
for (let pid of buf.match(/\d+/g)) {