Front end of the Slack clone application.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 'use strict';
  2. var cp = require('child_process');
  3. var parse = require('./lib/parse');
  4. var enoent = require('./lib/enoent');
  5. var cpSpawnSync = cp.spawnSync;
  6. function spawn(command, args, options) {
  7. var parsed;
  8. var spawned;
  9. // Parse the arguments
  10. parsed = parse(command, args, options);
  11. // Spawn the child process
  12. spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
  13. // Hook into child process "exit" event to emit an error if the command
  14. // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
  15. enoent.hookChildProcess(spawned, parsed);
  16. return spawned;
  17. }
  18. function spawnSync(command, args, options) {
  19. var parsed;
  20. var result;
  21. if (!cpSpawnSync) {
  22. try {
  23. cpSpawnSync = require('spawn-sync'); // eslint-disable-line global-require
  24. } catch (ex) {
  25. throw new Error(
  26. 'In order to use spawnSync on node 0.10 or older, you must ' +
  27. 'install spawn-sync:\n\n' +
  28. ' npm install spawn-sync --save'
  29. );
  30. }
  31. }
  32. // Parse the arguments
  33. parsed = parse(command, args, options);
  34. // Spawn the child process
  35. result = cpSpawnSync(parsed.command, parsed.args, parsed.options);
  36. // Analyze if the command does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
  37. result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
  38. return result;
  39. }
  40. module.exports = spawn;
  41. module.exports.spawn = spawn;
  42. module.exports.sync = spawnSync;
  43. module.exports._parse = parse;
  44. module.exports._enoent = enoent;