UNPKG

datainout

Version:

Import and reports data

35 lines (32 loc) 1.41 kB
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw Error('Dynamic require of "' + x + '" is not supported'); }); // src/helpers/datainout-config.ts import * as path from "path"; import * as fs from "fs"; var globalConfig = {}; function getConfig() { if (Object.keys(globalConfig).length === 0) { const jsPath = path.join(process.cwd(), "datainout.config.js"); const tsPath = path.join(process.cwd(), "datainout.config.ts"); if (fs.existsSync(jsPath)) globalConfig = __require(jsPath); else if (fs.existsSync(tsPath)) globalConfig = __require(tsPath).default; else globalConfig = { templateExtension: ".js", dateFormat: "DD-MM-YYYY" }; } return globalConfig; } // src/template-generators/TemplateGenerator.ts var TemplateGenerator = class { constructor(templatePath, functionPathFormat) { var _a; this.functionPathFormat = functionPathFormat; this.templatePath = this.functionPathFormat(templatePath != null ? templatePath : "", "templateDir"); this.templatePath = `${this.templatePath}${((_a = getConfig()) == null ? void 0 : _a.templateExtension) === ".ts" ? ".ts" : ".js"}`; } }; export { TemplateGenerator };