版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

37 строки
1.2 KiB

  1. "use strict";
  2. const Process = require("./process");
  3. const ProcessError = require("./process-error");
  4. module.exports = normalizeResult;
  5. /**
  6. * @param {string} [command] - The command used to run the process
  7. * @param {string[]} [args] - The command-line arguments that were passed to the process
  8. * @param {number} [pid] - The process ID
  9. * @param {string|Buffer} [stdout] - The process's stdout
  10. * @param {string|Buffer} [stderr] - The process's stderr
  11. * @param {string[]|Buffer[]} [output] - The process's stdio
  12. * @param {number} [status] - The process's status code
  13. * @param {string} [signal] - The signal that was used to kill the process, if any
  14. * @param {object} [options] - The options used to run the process
  15. * @param {Error} [error] - An error, if one occurred
  16. * @returns {Process}
  17. */
  18. function normalizeResult ({ command, args, pid, stdout, stderr, output, status, signal, options, error }) {
  19. let process = new Process({ command, args, pid, stdout, stderr, output, status, signal, options });
  20. if (error) {
  21. if (process.status === undefined) {
  22. process.status = null;
  23. }
  24. throw Object.assign(error, process);
  25. }
  26. else if (process.status) {
  27. throw new ProcessError(process);
  28. }
  29. else {
  30. return process;
  31. }
  32. }