From c21d67b130ed5ed7dd72d0c9e09f3ca371d9e9a3 Mon Sep 17 00:00:00 2001 From: CPTProgrammer <46586216+CPTProgrammer@users.noreply.github.com> Date: Thu, 16 Jul 2026 11:39:13 +0800 Subject: [PATCH] Use project root constant instead of process.cwd() --- root.ts | 1 + src/services/clients.ts | 3 ++- src/services/config.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 root.ts diff --git a/root.ts b/root.ts new file mode 100644 index 0000000..e98bf33 --- /dev/null +++ b/root.ts @@ -0,0 +1 @@ +export const PROJECT_ROOT = __dirname; diff --git a/src/services/clients.ts b/src/services/clients.ts index 839636d..10d89e9 100644 --- a/src/services/clients.ts +++ b/src/services/clients.ts @@ -4,9 +4,10 @@ import { ModrinthClient } from "@/lib/modrinth"; import { CurseForgeClient } from "@/lib/curseforge"; import type { Secrets } from "@/types"; import { SecretsSchema } from "@/types"; +import { PROJECT_ROOT } from "root"; function loadSecrets(): Secrets { - const secretsPath = path.join(process.cwd(), "secrets.json"); + const secretsPath = path.join(PROJECT_ROOT, "secrets.json"); let raw: unknown; try { diff --git a/src/services/config.ts b/src/services/config.ts index aa2109c..0bab53e 100644 --- a/src/services/config.ts +++ b/src/services/config.ts @@ -3,9 +3,10 @@ import { readdir, readFile, writeFile, unlink } from "fs/promises"; import path from "path"; import { ConfigSchema, type Config } from "@/types"; +import { PROJECT_ROOT } from "root"; function configDir(): string { - return path.join(process.cwd(), "configs"); + return path.join(PROJECT_ROOT, "configs"); } function configPath(name: string): string {