feat: add arg outpath
This commit is contained in:
		
							parent
							
								
									38f82409bd
								
							
						
					
					
						commit
						d2010834b7
					
				
					 1 changed files with 17 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -47,21 +47,33 @@ async function readContent(path?: string):Promise<string>{
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
if(import.meta.main){
 | 
			
		||||
    const args = argParse(Deno.args);
 | 
			
		||||
    
 | 
			
		||||
    const url = new URL(import.meta.url)
 | 
			
		||||
    url.pathname = normalize(pathJoin(url.pathname,"..","template"));
 | 
			
		||||
    const path = fromFileUrl(url);
 | 
			
		||||
    console.log(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 issues = JSON.parse(c) as Issue[];
 | 
			
		||||
 | 
			
		||||
    let print: string = "";
 | 
			
		||||
    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)
 | 
			
		||||
        });
 | 
			
		||||
        console.log(c);
 | 
			
		||||
        }) as string;
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
        printContent(issues);
 | 
			
		||||
    }
 | 
			
		||||
    if(args.outpath){
 | 
			
		||||
        Deno.writeTextFileSync(args.outpath,print);
 | 
			
		||||
    }
 | 
			
		||||
    else{
 | 
			
		||||
        console.log(print);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue