Initial Version (Working relay implementing basic functionality)

This commit is contained in:
Danny Morabito 2025-02-07 13:22:49 +01:00
commit aeae39df4d
Signed by: dannym
GPG key ID: 7CC8056A5A04557E
15 changed files with 1272 additions and 0 deletions

31
utils/files.ts Normal file
View file

@ -0,0 +1,31 @@
import { exists } from "jsr:@std/fs";
/**
* Return the path to Eve's configuration directory.
*
* The configuration directory is resolved in the following order:
* 1. The value of the `XDG_CONFIG_HOME` environment variable.
* 2. The value of the `HOME` environment variable, with `.config` appended.
*
* If the resolved path does not exist, create it.
*/
export async function getEveConfigHome(): Promise<string> {
const xdgConfigHome = Deno.env.get("XDG_CONFIG_HOME") ??
`${Deno.env.get("HOME")}/.config`;
const storagePath = `${xdgConfigHome}/arx/Eve`;
if (!(await exists(storagePath))) {
await Deno.mkdir(storagePath, { recursive: true });
}
return storagePath;
}
/**
* Return the path to the file in Eve's configuration directory.
*
* @param file The name of the file to return the path for.
* @returns The path to the file in Eve's configuration directory.
*/
export async function getEveFilePath(file: string): Promise<string> {
const storagePath = await getEveConfigHome();
return `${storagePath}/${file}`;
}