1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const lodash_1 = __importDefault(require("lodash"));
|
7 | const fs_extra_1 = __importDefault(require("fs-extra"));
|
8 | async function templateFile(templateFilePath, envs, outputFilePath, { mustache = true } = {}) {
|
9 | const templateString = await fs_extra_1.default.readFile(templateFilePath, 'utf8');
|
10 | const compiledTemplate = lodash_1.default.template(templateString, mustache
|
11 | ? {
|
12 |
|
13 | interpolate: /{{([\s\S]+?)}}/g,
|
14 | }
|
15 | : undefined);
|
16 | const outputFileContents = compiledTemplate(envs);
|
17 | if (outputFilePath) {
|
18 | await fs_extra_1.default.writeFile(outputFilePath, outputFileContents);
|
19 | }
|
20 | else {
|
21 | return outputFileContents;
|
22 | }
|
23 | }
|
24 | exports.default = templateFile;
|
25 |
|
\ | No newline at end of file |