add version number to audit
This commit is contained in:
+13
-5
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user