mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
20 lines
366 B
TypeScript
20 lines
366 B
TypeScript
import { readFile } from "fs/promises";
|
|
import { Observable } from "../../observable";
|
|
import { watch } from "fs";
|
|
|
|
type FileOptions = {
|
|
path: string;
|
|
};
|
|
|
|
const createFile = ({ path }: FileOptions) => {
|
|
const file = new Observable(async () => readFile(path, "utf-8"));
|
|
|
|
watch(path, () => {
|
|
file.recreate();
|
|
});
|
|
|
|
return file;
|
|
};
|
|
|
|
export { createFile };
|