From e1c849d3ec34afd67dbed1705c34ca7bc1168b7e Mon Sep 17 00:00:00 2001 From: Rizky Date: Wed, 7 Feb 2024 19:08:27 +0700 Subject: [PATCH] wip fix --- pkgs/core/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/core/index.ts b/pkgs/core/index.ts index fd8a9f0d..5101cc3b 100644 --- a/pkgs/core/index.ts +++ b/pkgs/core/index.ts @@ -1,12 +1,8 @@ -import { g } from "./utils/global"; - -g.mode = process.argv.includes("dev") ? "dev" : "prod"; -g.datadir = dir.path(g.mode === "prod" ? "../data" : "data", false); - import { parcelBuild } from "utils/parcel"; import { prepareAPITypes } from "./server/api/prep-api-ts"; import { startDevWatcher } from "./utils/dev-watcher"; import { ensureNotRunning } from "./utils/ensure"; +import { g } from "./utils/global"; import { createLogger } from "./utils/logger"; import { preparePrisma } from "./utils/prisma"; import { syncActionDefinition } from "utils/sync-def"; @@ -17,6 +13,7 @@ import { createId } from "@paralleldrive/cuid2"; import { prepareApiRoutes } from "./server/api/api-scan"; import { writeAsync } from "fs-jetpack"; import { dir } from "dir"; +import { join } from "path"; import { watchApiRoutes } from "./server/api/api-watch"; // import "../docker-prep"; @@ -33,7 +30,14 @@ if (!g.Y) { await createLogger(); g._api = {}; + g.mode = process.argv.includes("dev") ? "dev" : "prod"; + Object.defineProperty(g, "datadir", { + get: function () { + return join(process.cwd(), g.mode === "prod" ? "../data" : "data"); + }, + }); console.log("DataDir", g.datadir); + g.port = parseInt(process.env.PORT || "4550"); g.log.info(g.mode === "dev" ? "DEVELOPMENT" : "PRODUCTION");