fix watch
This commit is contained in:
parent
0a4a8e2009
commit
ceb30a6427
6
main.ts
6
main.ts
@ -81,10 +81,10 @@ if (import.meta.main){
|
||||
}
|
||||
)
|
||||
.command("user", user_command)
|
||||
.command("keyout", key_out_cmd)
|
||||
;
|
||||
.command("keyout", key_out_cmd);
|
||||
|
||||
await cmd.parse(Deno.args);
|
||||
}
|
||||
else {
|
||||
await start();
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user