import * as fs from 'fs' /** 读取单行 properties * 格式: key=vaue */ export const readSimpleProerties = (filePath: string): { [key: string]: any } => { if (!fs.existsSync(filePath)) return {} const fi = fs.readFileSync(filePath, { encoding: 'utf-8' }) return fi .split(/\n/g) .filter((line) => line.includes('=')) .map((line) => { const [key, value] = line.split(/=/) return { key, value } }) .reduce((props: { [key: string]: any }, item) => { props[item.key] = item.value return props }, {}) }