/** * 解析yaml,转化为api配置 */ /** * 进行解析 * * @param {{ path?: string, type: string, config?: any }} options * @returns {Record} */ export const doComply = (options: { path?: string, type: string, config?: any }): Record => { // 先去掉yml的解析方式,后续改为在入口判断platform走不同文件 if (options.type === 'object' || options.config) { // 支持直接传入对象使用 return options.config } else { return {} } // if (options.type === 'yml') { // // vite环境中执行会有问题 // const __dirname = path.resolve(path.dirname('')) // const file_path = path.resolve(__dirname, options.path) // const buffer = require('fs').readFileSync(file_path, 'utf8') // const config = require('yaml').parse(buffer) // return config // } else if (options.type === 'object' || options.config) { // // 支持直接传入对象使用 // return options.config // } else { // return {} // } } export default { doComply }