()
| 121 | const backupExists = await fs.access(this.backupPath).then(() => true).catch(() => false); |
| 122 | if (backupExists) { |
| 123 | await fs.copyFile(this.backupPath, this.configPath); |
| 124 | console.log("[zpr] 从备份恢复配置成功"); |
| 125 | } |
| 126 | } catch (error) { |
| 127 | console.error("[zpr] 备份恢复失败:", error); |
| 128 | await this.createDefaultConfig(); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | private static async createDefaultConfig(): Promise<void> { |
| 133 | await fs.writeFile(this.configPath, JSON.stringify(DEFAULT_CONFIG, null, 2)); |
| 134 | console.log("[zpr] 创建默认配置"); |
| 135 | } |
| 136 | |
| 137 | private static async handleInitError(): Promise<void> { |
no test coverage detected