mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
init
This commit is contained in:
19
bin/resources/file/index.ts
Normal file
19
bin/resources/file/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user