mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
21 lines
618 B
TypeScript
21 lines
618 B
TypeScript
import { join } from "path";
|
|
import { exists, mkdir, writeFile, readFile } from "fs/promises";
|
|
|
|
export const writeToTempDirectory = async (filename: string, data: string) => {
|
|
const tempDir = join("/tmp/", "lysand");
|
|
if (!(await exists(tempDir))) await mkdir(tempDir);
|
|
|
|
const tempFile = join(tempDir, filename);
|
|
await writeFile(tempFile, data);
|
|
|
|
return tempFile;
|
|
};
|
|
|
|
export const readFromTempDirectory = async (filename: string) => {
|
|
const tempDir = join("/tmp/", "lysand");
|
|
if (!(await exists(tempDir))) await mkdir(tempDir);
|
|
|
|
const tempFile = join(tempDir, filename);
|
|
return readFile(tempFile, "utf-8");
|
|
};
|