feat: add arg outpath
This commit is contained in:
parent
38f82409bd
commit
d2010834b7
@ -47,21 +47,33 @@ async function readContent(path?: string):Promise<string>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(import.meta.main){
|
if(import.meta.main){
|
||||||
|
const args = argParse(Deno.args);
|
||||||
|
|
||||||
const url = new URL(import.meta.url)
|
const url = new URL(import.meta.url)
|
||||||
url.pathname = normalize(pathJoin(url.pathname,"..","template"));
|
url.pathname = normalize(pathJoin(url.pathname,"..","template"));
|
||||||
const path = fromFileUrl(url);
|
const path = fromFileUrl(url);
|
||||||
console.log(path);
|
|
||||||
Eta.configure({views: path});
|
Eta.configure({views: path});
|
||||||
let args = argParse(Deno.args);
|
|
||||||
|
if(typeof args.path !== "string"){
|
||||||
|
console.log("Please provide a path to the json file.");
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
const c = await readContent(args.path);
|
const c = await readContent(args.path);
|
||||||
const issues = JSON.parse(c) as Issue[];
|
const issues = JSON.parse(c) as Issue[];
|
||||||
|
|
||||||
|
let print: string = "";
|
||||||
if(args.overall){
|
if(args.overall){
|
||||||
const c = await Eta.renderFile("overall.md.eta",{
|
print = await Eta.renderFile("overall.md.eta",{
|
||||||
issues: issues.sort((a,b)=>a.number-b.number)
|
issues: issues.sort((a,b)=>a.number-b.number)
|
||||||
});
|
}) as string;
|
||||||
console.log(c);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
printContent(issues);
|
printContent(issues);
|
||||||
}
|
}
|
||||||
|
if(args.outpath){
|
||||||
|
Deno.writeTextFileSync(args.outpath,print);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log(print);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user