From 220416c734580866d71a3b40b14ad79f51ba8707 Mon Sep 17 00:00:00 2001 From: monoid Date: Thu, 21 Apr 2022 01:05:01 +0900 Subject: [PATCH] add w option alias watch --- tools/printDocument.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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") {