diff --git a/tools/printDocument.ts b/tools/printDocument.ts index 15cdc98..2339eed 100644 --- a/tools/printDocument.ts +++ b/tools/printDocument.ts @@ -15,6 +15,7 @@ async function readContent(path?: string): Promise { const buf = await readAll(Deno.stdin); content = decoder.decode(buf); } + else throw new Error("No input provided. path or stdin."); return content; } @@ -47,8 +48,8 @@ async function readAndPrint(args: { async function main() { const parsedArg = argParse(Deno.args); - const { path, outpath, overall, w } = parsedArg; - + const { path, outpath, overall, w, watch } = parsedArg; + const watchMode = w || watch; if (typeof path !== "undefined" && typeof path !== "string") { console.log("Please provide a path to the json file."); Deno.exit(1); @@ -61,11 +62,11 @@ async function main() { console.log("Please provide a boolean value for overall."); Deno.exit(1); } - if (typeof w !== "undefined" && typeof w !== "boolean") { + if (typeof watchMode !== "undefined" && typeof watchMode !== "boolean") { console.log("Please provide a boolean value for w."); Deno.exit(1); } - if (w && typeof path === "undefined") { + if (watchMode && typeof path === "undefined") { console.log("Could not set watch mode without a path."); Deno.exit(1); } @@ -82,7 +83,7 @@ async function main() { const issues = JSON.parse(c) as Issue[]; issues.sort((a, b) => a.number - b.number); await readAndPrint({ path, outpath, overall }); - if (w) { + if (watchMode) { const watcher = Deno.watchFs([viewPath, path as string]); for await (const event of watcher) { if (event.kind === "modify") {