index.js 501 B

123456789101112131415161718
  1. const reorder = require('./lib/reorder');
  2. const respawn = require('./lib/respawn');
  3. module.exports = function (flags, argv, execute) {
  4. if (!flags) {
  5. throw new Error('You must specify flags to respawn with.');
  6. }
  7. if (!argv) {
  8. throw new Error('You must specify an argv array.');
  9. }
  10. var proc = process;
  11. var reordered = reorder(flags, argv);
  12. var ready = JSON.stringify(argv) === JSON.stringify(reordered);
  13. if (!ready) {
  14. proc = respawn(reordered);
  15. }
  16. execute(ready, proc);
  17. };