fix
This commit is contained in:
parent
e9e259d0cf
commit
2c40b191ef
|
|
@ -1,12 +1,13 @@
|
||||||
import { FSWatcher, statSync, watch } from "fs";
|
import { FSWatcher, statSync, watch } from "fs";
|
||||||
import { readdir } from "node:fs/promises";
|
import { readdir } from "node:fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
import { code } from "../../code";
|
||||||
|
|
||||||
const path = process.argv.splice(2).join(" ");
|
const path = process.argv.splice(2).join(" ");
|
||||||
|
|
||||||
const watchers = {} as Record<string, FSWatcher>;
|
const watchers = {} as Record<string, FSWatcher>;
|
||||||
|
|
||||||
const createWatcher = (p: string, recursive: boolean) => {
|
const createWatcher = (p: string, recursive: boolean, prefix?: string) => {
|
||||||
return watch(p, { recursive }, (e, filename) => {
|
return watch(p, { recursive }, (e, filename) => {
|
||||||
if (filename === "global.d.ts") return;
|
if (filename === "global.d.ts") return;
|
||||||
if (
|
if (
|
||||||
|
|
@ -15,7 +16,7 @@ const createWatcher = (p: string, recursive: boolean) => {
|
||||||
filename?.endsWith(".css") ||
|
filename?.endsWith(".css") ||
|
||||||
filename?.endsWith(".html")
|
filename?.endsWith(".html")
|
||||||
) {
|
) {
|
||||||
process.send?.([e, filename]);
|
process.send?.([e, (prefix || "") + filename]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -27,7 +28,7 @@ for (const file of files) {
|
||||||
const fullpath = join(path, file);
|
const fullpath = join(path, file);
|
||||||
const stats = statSync(fullpath);
|
const stats = statSync(fullpath);
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
watchers[file] = createWatcher(fullpath, true);
|
watchers[file] = createWatcher(fullpath, true, `${file}/`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setInterval(() => {}, 1e9);
|
setInterval(() => {}, 1e9);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue