市场夺宝奇兵
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
782 B

  1. import {DiscardedError} from '../return/final-error.js';
  2. import {isMaxBufferSync} from '../io/max-buffer.js';
  3. import {isFailedExit} from './exit-async.js';
  4. // Retrieve exit code, signal name and error information, with synchronous methods
  5. export const getExitResultSync = ({error, status: exitCode, signal, output}, {maxBuffer}) => {
  6. const resultError = getResultError(error, exitCode, signal);
  7. const timedOut = resultError?.code === 'ETIMEDOUT';
  8. const isMaxBuffer = isMaxBufferSync(resultError, output, maxBuffer);
  9. return {
  10. resultError,
  11. exitCode,
  12. signal,
  13. timedOut,
  14. isMaxBuffer,
  15. };
  16. };
  17. const getResultError = (error, exitCode, signal) => {
  18. if (error !== undefined) {
  19. return error;
  20. }
  21. return isFailedExit(exitCode, signal) ? new DiscardedError() : undefined;
  22. };