UNPKG

datainout

Version:

Import and reports data

42 lines (38 loc) 1.72 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/path-file.ts import * as path2 from "path"; // 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/helpers/path-file.ts var config = getConfig(); function pathReport(_path, fieldName) { var _a; if (!(config == null ? void 0 : config.report) || !fieldName || !((_a = config == null ? void 0 : config.report) == null ? void 0 : _a[fieldName])) return path2.join(process.cwd(), _path); return path2.join(process.cwd(), config.report[fieldName], _path); } function pathImport(_path, fieldName) { var _a; if (!(config == null ? void 0 : config.import) || !fieldName || !((_a = config == null ? void 0 : config.import) == null ? void 0 : _a[fieldName])) return path2.join(process.cwd(), _path); return path2.join(process.cwd(), config.import[fieldName], _path); } export { pathImport, pathReport };