spawn-command.js 767 B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const _ = require('lodash');
  3. const spawn = require('cross-spawn');
  4. /**
  5. * @mixin
  6. * @alias actions/spawn-command
  7. */
  8. const spawnCommand = module.exports;
  9. /**
  10. * Normalize a command across OS and spawn it (asynchronously).
  11. *
  12. * @param {String} command
  13. * @param {Array} args
  14. * @param {object} [opt]
  15. */
  16. spawnCommand.spawnCommand = (command, args, opt) => {
  17. opt = opt || {};
  18. return spawn(command, args, _.defaults(opt, {stdio: 'inherit'}));
  19. };
  20. /**
  21. * Normalize a command across OS and spawn it (synchronously).
  22. *
  23. * @param {String} command
  24. * @param {Array} args
  25. * @param {object} [opt]
  26. */
  27. spawnCommand.spawnCommandSync = (command, args, opt) => {
  28. opt = opt || {};
  29. return spawn.sync(command, args, _.defaults(opt, {stdio: 'inherit'}));
  30. };