Skip to content

Commit

Permalink
Use package.json to store Titan configuration paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrushC committed Sep 20, 2024
1 parent b27465d commit d4d0bd5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { fileURLToPath } from "url";
import { setupLogger, setupUncaughtExceptionHandler } from "./server/logger.js";
import { exec } from "child_process";

// Import package.json
import packageJson from "./package.json" assert { type: "json" };

const { autoUpdater } = electronUpdaterPkg;

const __filename = fileURLToPath(import.meta.url);
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"main": "main.js",
"description": "A desktop application for streamlining your workflow in Revision Control Systems (RCS) like Subversion (SVN).",
"author": "ArrushC",
"configFolderPath": "C:/Titan",
"configFilePath": "C:/Titan/Titan.config.json",
"targetsFilePath": "C:/Titan/Titan.targets.txt",
"logFilePath": "C:/Titan/Titan.app.log",
"scripts": {
"start": "npm run server:start",
"client:dev": "vite",
Expand Down
5 changes: 4 additions & 1 deletion server/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import { createLogger, format, transports } from "winston";
import fs from "fs";
import path from "path";

// Import package.json
import packageJson from "../package.json" assert { type: "json" };

const { combine, timestamp, printf, errors } = format;

const myFormat = printf(({ level, message, timestamp, stack, label }) => {
return `${timestamp} [${label}] [${level}]: ${stack || message}`;
});

export const logFilePath = "C:/Titan/Titan.app.log";
export const logFilePath = packageJson.logFilePath;

// Ensure the log file exists
const logDir = path.dirname(logFilePath);
Expand Down
4 changes: 2 additions & 2 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const server = createServer(app);
const io = new Server(server);

const latestVersion = packageJson.version;
const configFilePath = "C:/Titan/Titan.config.json";
const targetsFilePath = "C:/Titan/Titan.targets.txt";
const configFilePath = packageJson.configFilePath;
const targetsFilePath = packageJson.targetsFilePath;

// Use compression middleware
app.use(compression());
Expand Down

0 comments on commit d4d0bd5

Please sign in to comment.