add version number to audit

This commit is contained in:
marlon-erler
2024-07-07 18:20:37 +02:00
parent 9a42fc047f
commit 9a9b8f1ee5
2 changed files with 25 additions and 11 deletions
+13 -5
View File
@@ -1,19 +1,27 @@
import Colors from "colors";
import Fs from "fs/promises";
import { PACKAGE_FILE } from ".";
import { WebSocketMessage } from "./websocket-handler";
// CONFIG
const STAT_INDENT = 25;
// SAFETY
export function doIfIsString(
data: any,
cb: (data: string) => void
): void {
// MISC
export function doIfIsString(data: any, cb: (data: string) => void): void {
if (typeof data != "string" || data == "") return;
cb(data);
}
export async function getVersionNumber(): Promise<string> {
try {
const packageString = await Bun.file(PACKAGE_FILE).text();
const packageObject = JSON.parse(packageString);
return packageObject.version;
} catch {
return "unknown";
}
}
// OUTPUT
async function writeToLogFile(message: string): Promise<void> {
await Fs.appendFile("logs", `${message}\n`);