From 6d7c36af98122e1643c1187635058669c87e70c2 Mon Sep 17 00:00:00 2001 From: Brian Richter Date: Fri, 6 Oct 2023 13:46:50 -0700 Subject: [PATCH] move template dir --- package.json | 2 +- src/Generator.ts | 9 +++++---- src/Run.ts | 5 +++++ assets/hrg-template.mustache => template.mustache | 0 4 files changed, 11 insertions(+), 5 deletions(-) rename assets/hrg-template.mustache => template.mustache (100%) diff --git a/package.json b/package.json index 6b699a0..e6ac415 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aviarytech/tev2-hrgt", - "version": "0.0.6", + "version": "0.0.7", "description": "Human Readable Glossary Tool (HRGT)", "main": "lib/Run.js", "types": "lib/Run.d.ts", diff --git a/src/Generator.ts b/src/Generator.ts index 2b8167a..1616d1f 100644 --- a/src/Generator.ts +++ b/src/Generator.ts @@ -13,23 +13,27 @@ export class Generator { private glossary!: Glossary; private entries: Entry[]; private htmlOutput!: string; + private template: string; public constructor({ method, scopedir, input, output, + template, }: { method: any; scopedir: string; input: string; output: string; + template: string; }) { this.entries = []; this.method = method; this.scopedir = scopedir; this.inputGlob = input; this.outputName = output; + this.template = template; log.info( `Using ${this.method} method with MRG ${ this.inputGlob ?? "(from SAF scope.mrgfile)" @@ -77,10 +81,7 @@ export class Generator { private async generateHTML(): Promise { try { - const templateFile = fs.readFileSync( - "./assets/hrg-template.mustache", - "utf8" - ); + const templateFile = fs.readFileSync(this.template, "utf8"); const template = Handlebars.compile(templateFile); this.htmlOutput = template({ entries: this.entries }); } catch (error) { diff --git a/src/Run.ts b/src/Run.ts index 82b3b28..a535ada 100644 --- a/src/Run.ts +++ b/src/Run.ts @@ -50,6 +50,10 @@ program "-t, --termselcriteria", "List of term selection criteria that are used to generate" ) + .option( + "-te, --template", + "Path (including the filename) of the mustache template file" + ) .option( "-m, --method", "The method that is used to create the output (default HTML)" @@ -96,6 +100,7 @@ async function main(): Promise { scopedir: options.scopedir ?? ".", input: options.input, output: options.output ?? "default", + template: options.template ?? "template.mustache", }); // Resolve terms diff --git a/assets/hrg-template.mustache b/template.mustache similarity index 100% rename from assets/hrg-template.mustache rename to template.mustache