Use project root constant instead of process.cwd()

This commit is contained in:
CPTProgrammer 2026-07-16 11:39:13 +08:00
parent 7173ef1149
commit c21d67b130
No known key found for this signature in database
3 changed files with 5 additions and 2 deletions

1
root.ts Normal file
View File

@ -0,0 +1 @@
export const PROJECT_ROOT = __dirname;

View File

@ -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 {

View File

@ -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 {