UNPKG

maddis-tsc-junit

Version:

JUnit report generator for typescript

34 lines (33 loc) 1.1 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadConfig = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = require("path"); async function loadConfig(configFile) { if (!configFile) return undefined; const location = (0, path_1.join)(process.cwd(), configFile); let parsed; try { const source = await fs_1.default.promises.readFile(location, 'utf-8'); parsed = JSON.parse(source); } catch (_a) { throw new Error(`Failed to parse config: ${configFile}`); } const references = []; if (typeof parsed === 'object' && Array.isArray(parsed.references)) { for (const reference of parsed.references) { if (typeof reference === 'object' && typeof reference.path === 'string') { references.push(reference); } } } return { references, }; } exports.loadConfig = loadConfig;