diff options
| author | Kevin J Hoerr <kjhoerr@protonmail.com> | 2021-09-25 17:33:23 +0000 |
|---|---|---|
| committer | Kevin J Hoerr <kjhoerr@protonmail.com> | 2021-09-25 17:33:23 +0000 |
| commit | 283c3f14760c925fe9bf51a2db6f2d567dedb4fe (patch) | |
| tree | e3617b15b1493788bbf37f957be81aacac4ffdf6 /src/templates.ts | |
| parent | dd829249122948fd66dd885dbd39a0cd9167118d (diff) | |
| download | ao-coverage-283c3f14760c925fe9bf51a2db6f2d567dedb4fe.tar.gz ao-coverage-283c3f14760c925fe9bf51a2db6f2d567dedb4fe.tar.bz2 ao-coverage-283c3f14760c925fe9bf51a2db6f2d567dedb4fe.zip | |
Add lint check to pipeline
Diffstat (limited to 'src/templates.ts')
| -rw-r--r-- | src/templates.ts | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/templates.ts b/src/templates.ts index 5458a36..648bb56 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -4,23 +4,20 @@ import fs from "fs"; export interface Template { inputFile: string; outputFile: string; - context: object; - data: string | undefined; + context: Record<string, string>; + data?: string; } -export default (_template: Template): Promise<Template> => - fs.promises - .readFile(_template.inputFile, "utf-8") - .then(buffer => { - const translate = handlebars.compile(buffer); +export default async (_template: Template): Promise<Template> => { + const buffer = await fs.promises.readFile(_template.inputFile, "utf-8"); - return { - ..._template, - data: translate(_template.context) - }; - }) - .then(template => - fs.promises - .writeFile(template.outputFile, template.data) - .then(() => template) - ); + const translate = handlebars.compile(buffer); + const template = { + ..._template, + data: translate(_template.context), + }; + + await fs.promises.writeFile(template.outputFile, template.data); + + return template; +}; |
