UNPKG

995 BJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const lodash_1 = __importDefault(require("lodash"));
7const fs_extra_1 = __importDefault(require("fs-extra"));
8async 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 // mustache
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}
24exports.default = templateFile;
25//# sourceMappingURL=templateFile.js.map
\No newline at end of file