add w option alias watch
This commit is contained in:
parent
d771810eff
commit
220416c734
@ -15,6 +15,7 @@ async function readContent(path?: string): Promise<string> {
|
|||||||
const buf = await readAll(Deno.stdin);
|
const buf = await readAll(Deno.stdin);
|
||||||
content = decoder.decode(buf);
|
content = decoder.decode(buf);
|
||||||
}
|
}
|
||||||
|
else throw new Error("No input provided. path or stdin.");
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +48,8 @@ async function readAndPrint(args: {
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const parsedArg = argParse(Deno.args);
|
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") {
|
if (typeof path !== "undefined" && typeof path !== "string") {
|
||||||
console.log("Please provide a path to the json file.");
|
console.log("Please provide a path to the json file.");
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
@ -61,11 +62,11 @@ async function main() {
|
|||||||
console.log("Please provide a boolean value for overall.");
|
console.log("Please provide a boolean value for overall.");
|
||||||
Deno.exit(1);
|
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.");
|
console.log("Please provide a boolean value for w.");
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
if (w && typeof path === "undefined") {
|
if (watchMode && typeof path === "undefined") {
|
||||||
console.log("Could not set watch mode without a path.");
|
console.log("Could not set watch mode without a path.");
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
@ -82,7 +83,7 @@ async function main() {
|
|||||||
const issues = JSON.parse(c) as Issue[];
|
const issues = JSON.parse(c) as Issue[];
|
||||||
issues.sort((a, b) => a.number - b.number);
|
issues.sort((a, b) => a.number - b.number);
|
||||||
await readAndPrint({ path, outpath, overall });
|
await readAndPrint({ path, outpath, overall });
|
||||||
if (w) {
|
if (watchMode) {
|
||||||
const watcher = Deno.watchFs([viewPath, path as string]);
|
const watcher = Deno.watchFs([viewPath, path as string]);
|
||||||
for await (const event of watcher) {
|
for await (const event of watcher) {
|
||||||
if (event.kind === "modify") {
|
if (event.kind === "modify") {
|
||||||
|
Loading…
Reference in New Issue
Block a user