From c64a32abd5e68080921574a735ee2804fb2a9212 Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Sat, 31 Oct 2026 02:01:48 -0700 Subject: [PATCH] refactor(hub): check the signing key's EEXIST with hasCode --- apps/hub/src/signing-key.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/hub/src/signing-key.ts b/apps/hub/src/signing-key.ts index a9132722..ff2e9913 100644 --- a/apps/hub/src/signing-key.ts +++ b/apps/hub/src/signing-key.ts @@ -1,7 +1,7 @@ import { mkdir, readFile, writeFile, lstat } from "node:fs/promises"; import { join } from "node:path"; import { derivePublicKeyBytes, generateKeyPair } from "@intx/crypto"; -import { hexDecode, hexEncode } from "@intx/types"; +import { hasCode, hexDecode, hexEncode } from "@intx/types"; export async function loadHubSigningKey(dataDir: string) { await mkdir(dataDir, { recursive: true, mode: 0o700 }); @@ -13,8 +13,7 @@ export async function loadHubSigningKey(dataDir: string) { mode: 0o600, }); } catch (error) { - if (!(error instanceof Error && "code" in error && error.code === "EEXIST")) - throw error; + if (!(hasCode(error) && error.code === "EEXIST")) throw error; } const info = await lstat(file); if (!info.isFile() || (info.mode & 0o077) !== 0) {