From 21dcf4decd81ec26f02174f5070e0ebd195ebadb Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 6 Jul 2022 17:42:54 +0100 Subject: [PATCH] Fixing an issue with running in dev with prebuilds and fixing an issue with backup questions being asked twice. --- packages/cli/src/backups/index.js | 1 - packages/cli/src/prebuilds.js | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/backups/index.js b/packages/cli/src/backups/index.js index e157e484fa..697dafac6f 100644 --- a/packages/cli/src/backups/index.js +++ b/packages/cli/src/backups/index.js @@ -17,7 +17,6 @@ const { exportObjects, importObjects } = require("./objectStore") async function exportBackup(opts) { const envFile = opts.env || undefined - await getConfig(envFile) let filename = opts["export"] || opts if (typeof filename !== "string") { filename = `backup-${new Date().toISOString()}.tar.gz` diff --git a/packages/cli/src/prebuilds.js b/packages/cli/src/prebuilds.js index a1a8a429ac..ecc59f964a 100644 --- a/packages/cli/src/prebuilds.js +++ b/packages/cli/src/prebuilds.js @@ -8,10 +8,10 @@ const PREBUILD_DIR = join(process.execPath, "..", PREBUILDS, ARCH) checkForBinaries() function checkForBinaries() { - if (fs.existsSync(PREBUILD_DIR)) { + const readDir = join(__filename, "..", "..", PREBUILDS, ARCH) + if (fs.existsSync(PREBUILD_DIR) || !fs.existsSync(readDir)) { return } - const readDir = join(__filename, "..", "..", PREBUILDS, ARCH) const natives = fs.readdirSync(readDir) if (fs.existsSync(readDir)) { fs.mkdirSync(PREBUILD_DIR, { recursive: true }) @@ -22,8 +22,13 @@ function checkForBinaries() { } } -process.on("exit", () => { +function cleanup() { if (fs.existsSync(PREBUILD_DIR)) { fs.rmSync(PREBUILD_DIR, { recursive: true }) } +} + +const events = ["exit", "SIGINT", "SIGUSR1", "SIGUSR2", "uncaughtException"] +events.forEach(event => { + process.on(event, cleanup) })