UNPKG

control-see

Version:

Control Util Documentos Electronicos SUNAT

49 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HtmlPdfUtils = void 0; const lodash_1 = require("lodash"); const fs = require("fs"); const path = require("path"); class HtmlPdfUtils { constructor() { } convertPath(filePath) { if (path.isAbsolute(filePath)) return filePath; return path.join(process.cwd(), filePath); } getTemplateFilePath({ templatePath, template = "html5bp" }) { if (templatePath) return templatePath; return path.resolve(path.join(__dirname, "..", "templates", template)); } readBodyOrFile(body, filePath) { if (body) { return lodash_1.toString(body); } if (!filePath) { return; } if (fs.statSync(filePath).isDirectory()) { return; } return fs.readFileSync(this.convertPath(filePath), "utf-8"); } convertIncludes(includes) { if (!includes || !Array.isArray(includes)) return []; return includes.map((include) => { if (typeof include === "string") { return { type: path.extname(include).replace(".", ""), filePath: include, }; } if (lodash_1.isPlainObject(include)) { return include; } }); } } exports.HtmlPdfUtils = HtmlPdfUtils; //# sourceMappingURL=html-pdf-utils.js.map