2024-08-07 09:51:26 +08:00

16 lines
635 B
TypeScript

import { getControledMihomoConfig, getCurrentProfile } from '../config'
import { mihomoWorkConfigPath } from '../utils/dirs'
import yaml from 'yaml'
import fs from 'fs'
export function generateProfile(): void {
const currentProfile = getCurrentProfile()
const controledMihomoConfig = getControledMihomoConfig()
const { tun: profileTun = {} } = currentProfile
const { tun: controledTun } = controledMihomoConfig
const tun = Object.assign(profileTun, controledTun)
const profile = Object.assign(currentProfile, controledMihomoConfig)
profile.tun = tun
fs.writeFileSync(mihomoWorkConfigPath(), yaml.stringify(profile))
}