message: chore(e2e): attempt to log better errors when running commands
diff: */
  import * as path from 'path';
  +import * as util from 'util';
  import dedent = require('dedent');
  -import {ExecaReturnValue, sync as spawnSync} from 'execa';
  +import {ExecaSyncError, ExecaSyncReturnValue, sync as spawnSync} from 'execa';
  import * as fs from 'graceful-fs';
  import which = require('which');
  import type {Config} from '@jest/types';
  -interface RunResult extends ExecaReturnValue {
  - status: number;
  - error: Error;
  -}
  export const run = (
  cmd: string,
  cwd?: string,
  env?: Record<string, string>,
  -): RunResult => {
  +): ExecaSyncReturnValue => {
  const args = cmd.split(/\s/).slice(1);
  const spawnOptions = {cwd, env, preferLocal: false, reject: false};
  - const result = spawnSync(cmd.split(/\s/)[0], args, spawnOptions) as RunResult;
  + const result = spawnSync(cmd.split(/\s/)[0], args, spawnOptions);
  - // For compat with cross-spawn
  - result.status = result.exitCode;
  + if (result.exitCode !== 0) {
  + const errorResult = result as ExecaSyncError;
  - if (result.status !== 0) {
  - throw new Error(dedent`
  - ORIGINAL CMD: ${cmd}
  - STDOUT: ${result.stdout}
  - STDERR: ${result.stderr}
  - STATUS: ${result.status}
  - ERROR: ${result.error}
  - `);
  + // have to extract message for the `util.inspect` to be useful for some reason
  + const {message, ...rest} = errorResult;
  +
  + errorResult.message += `\n\n${util.inspect(rest)}`;
  +
  + throw errorResult;
  }
  return result;
  