add pathHelper
This commit is contained in:
parent
71fb01402a
commit
1b6083f901
4
src/helpers/pathHelper.ts
Normal file
4
src/helpers/pathHelper.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import path from "path";
|
||||||
|
|
||||||
|
export const rootDir = path.join(__dirname, "../..");
|
||||||
|
export const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
|
@ -1,9 +1,8 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { repoDir, rootDir } from "@/src/helpers/pathHelper";
|
||||||
|
|
||||||
const webuiRouter = express.Router();
|
const webuiRouter = express.Router();
|
||||||
const rootDir = path.join(__dirname, "../..");
|
|
||||||
const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
|
|
||||||
|
|
||||||
// Redirect / to /webui/
|
// Redirect / to /webui/
|
||||||
webuiRouter.get("/", (_req, res) => {
|
webuiRouter.get("/", (_req, res) => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
import { repoDir } from "@/src/helpers/pathHelper";
|
||||||
|
|
||||||
interface IBuildConfig {
|
interface IBuildConfig {
|
||||||
version: string;
|
version: string;
|
||||||
@ -13,8 +14,6 @@ export const buildConfig: IBuildConfig = {
|
|||||||
matchmakingBuildId: ""
|
matchmakingBuildId: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
const rootDir = path.join(__dirname, "../..");
|
|
||||||
const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
|
|
||||||
const buildConfigPath = path.join(repoDir, "static/data/buildConfig.json");
|
const buildConfigPath = path.join(repoDir, "static/data/buildConfig.json");
|
||||||
if (fs.existsSync(buildConfigPath)) {
|
if (fs.existsSync(buildConfigPath)) {
|
||||||
Object.assign(buildConfig, JSON.parse(fs.readFileSync(buildConfigPath, "utf-8")) as IBuildConfig);
|
Object.assign(buildConfig, JSON.parse(fs.readFileSync(buildConfigPath, "utf-8")) as IBuildConfig);
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import path from "path";
|
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import fsPromises from "fs/promises";
|
import fsPromises from "fs/promises";
|
||||||
|
import path from "path";
|
||||||
|
import { repoDir } from "@/src/helpers/pathHelper";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
|
|
||||||
const rootDir = path.join(__dirname, "../..");
|
|
||||||
const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
|
|
||||||
const configPath = path.join(repoDir, "config.json");
|
const configPath = path.join(repoDir, "config.json");
|
||||||
export const config = JSON.parse(fs.readFileSync(configPath, "utf-8")) as IConfig;
|
export const config = JSON.parse(fs.readFileSync(configPath, "utf-8")) as IConfig;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user