(name: string, profile: AuthProfile)
| 84 | * 写入/更新一个 auth profile |
| 85 | */ |
| 86 | export function writeAuthProfile(name: string, profile: AuthProfile): void { |
| 87 | const configDir = getConfigDir() |
| 88 | if (!fs.existsSync(configDir)) { |
| 89 | fs.mkdirSync(configDir, { recursive: true }) |
| 90 | } |
| 91 | |
| 92 | const data = loadAuthProfiles() |
| 93 | data.profiles[name] = profile |
| 94 | |
| 95 | const filePath = getAuthProfilesPath() |
| 96 | fs.writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: 'utf-8', mode: 0o600 }) |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * 删除一个 auth profile |
no test coverage detected