fix watch

This commit is contained in:
monoid 2023-01-06 18:06:10 +09:00
parent 0a4a8e2009
commit ceb30a6427
2 changed files with 11 additions and 7 deletions

View File

@ -81,8 +81,8 @@ if (import.meta.main){
}
)
.command("user", user_command)
.command("keyout", key_out_cmd)
;
.command("keyout", key_out_cmd);
await cmd.parse(Deno.args);
}
else {

View File

@ -1,3 +1,4 @@
import { Index } from "../client_search.ts";
import { Doc, DocCollector } from "../collect.ts";
@ -7,13 +8,16 @@ export const docCollector = new DocCollector(
summaryOnly: true,
});
async function prepareDocs() {
export let docIndex: Index | undefined = undefined;
export async function prepareDocs() {
const docPath = Deno.env.get("COLLECT_DOC_PATH");
if (!docPath) {
await docCollector.walkDir(".");
return docCollector.makeIndex({
docIndex = docCollector.makeIndex({
watch: true
});
return docIndex;
}
try {
@ -30,11 +34,11 @@ async function prepareDocs() {
}
}
return docCollector.makeIndex({
docIndex = docCollector.makeIndex({
watch: true,
onUpdate: async () => {
await Deno.writeTextFile(docPath, JSON.stringify(docCollector.getDocs()));
}
});
return docIndex;
}
export const docIndex = await prepareDocs();