Initial Version (Working relay implementing basic functionality)
This commit is contained in:
commit
aeae39df4d
15 changed files with 1272 additions and 0 deletions
31
utils/files.ts
Normal file
31
utils/files.ts
Normal 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}`;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue