Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Replace exit-hook with custom event listeners
Sebastian Martinez committed 2 years ago
commit 0ab1d1ba41a9e3672eb0833df869ddc84f4ccfaf
parent 23895bd82615258e99802b2a83c34c33e949acde
3 files changed +4 -16
modified package-lock.json
@@ -48,7 +48,6 @@
        "eslint-plugin-no-only-tests": "^3.1.0",
        "eslint-plugin-svelte": "^2.35.0",
        "execa": "^8.0.1",
-
        "exit-hook": "^4.0.0",
        "get-port": "^7.0.0",
        "happy-dom": "^12.10.3",
        "prettier": "^3.1.0",
@@ -2326,18 +2325,6 @@
        "url": "https://github.com/sindresorhus/execa?sponsor=1"
      }
    },
-
    "node_modules/exit-hook": {
-
      "version": "4.0.0",
-
      "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-4.0.0.tgz",
-
      "integrity": "sha512-Fqs7ChZm72y40wKjOFXBKg7nJZvQJmewP5/7LtePDdnah/+FH9Hp5sgMujSCMPXlxOAW2//1jrW9pnsY7o20vQ==",
-
      "dev": true,
-
      "engines": {
-
        "node": ">=18"
-
      },
-
      "funding": {
-
        "url": "https://github.com/sponsors/sindresorhus"
-
      }
-
    },
    "node_modules/extend-shallow": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
modified package.json
@@ -38,7 +38,6 @@
    "eslint-plugin-no-only-tests": "^3.1.0",
    "eslint-plugin-svelte": "^2.35.0",
    "execa": "^8.0.1",
-
    "exit-hook": "^4.0.0",
    "get-port": "^7.0.0",
    "happy-dom": "^12.10.3",
    "prettier": "^3.1.0",
modified tests/support/process.ts
@@ -1,7 +1,6 @@
import type { ExecaChildProcess, Options } from "execa";

import * as Stream from "node:stream";
-
import onExit from "exit-hook";
import { StringDecoder } from "string_decoder";
import { execa } from "execa";

@@ -11,7 +10,9 @@ import { logPrefix } from "./logPrefix.js";
// We add all proxy and node instances that we spawn to this list.
const processes: ExecaChildProcess[] = [];

-
onExit(killAllProcesses);
+
process.on("exit", killAllProcesses);
+
process.on("SIGINT", killAllProcesses);
+
process.on("SIGTERM", killAllProcesses);

// Kill all processes with SIGKILL
export function killAllProcesses(): void {
@@ -20,6 +21,7 @@ export function killAllProcesses(): void {
      process.kill("SIGKILL");
    }
  }
+
  process.exit();
}

// Spawn a process with `execa` and register it.