UNPKG

poku

Version:

🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.

35 lines (34 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getConfigs = void 0; const promises_1 = require("fs/promises"); const node_path_1 = require("path"); const poku_js_1 = require("../configs/poku.js"); const jsonc_js_1 = require("../polyfills/jsonc.js"); const os_js_1 = require("./os.js"); const getConfigs = async (customPath) => { const expectedFiles = customPath ? [customPath] : new Set([ 'poku.config.js', 'poku.config.cjs', '.pokurc.json', '.pokurc.jsonc', ]); for (const file of expectedFiles) { const filePath = (0, node_path_1.join)(poku_js_1.GLOBAL.cwd, file); let path = ''; if (os_js_1.isWindows) path += 'file://'; path += (0, node_path_1.normalize)(filePath); try { if (filePath.endsWith('.js') || filePath.endsWith('.cjs')) return require(path); const configsFile = await (0, promises_1.readFile)(filePath, 'utf8'); return jsonc_js_1.JSONC.parse(configsFile); } catch { } } return Object.create(null); }; exports.getConfigs = getConfigs;