cli.js 612 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env node
  2. const electron = require('./');
  3. const proc = require('child_process');
  4. const child = proc.spawn(electron, process.argv.slice(2), { stdio: 'inherit', windowsHide: false });
  5. child.on('close', function (code, signal) {
  6. if (code === null) {
  7. console.error(electron, 'exited with signal', signal);
  8. process.exit(1);
  9. }
  10. process.exit(code);
  11. });
  12. const handleTerminationSignal = function (signal) {
  13. process.on(signal, function signalHandler () {
  14. if (!child.killed) {
  15. child.kill(signal);
  16. }
  17. });
  18. };
  19. handleTerminationSignal('SIGINT');
  20. handleTerminationSignal('SIGTERM');