(state: WatchState, ctx: CmdRunContext)
| 155 | } |
| 156 | |
| 157 | async function triggerRetranslation(state: WatchState, ctx: CmdRunContext) { |
| 158 | if (state.isRunning) return; |
| 159 | |
| 160 | state.isRunning = true; |
| 161 | |
| 162 | try { |
| 163 | const changedFiles = Array.from(state.pendingChanges); |
| 164 | state.pendingChanges.clear(); |
| 165 | |
| 166 | console.log(chalk.hex(colors.green)("\nš Triggering retranslation...")); |
| 167 | console.log(chalk.dim(`Changed files: ${changedFiles.join(", ")}`)); |
| 168 | console.log(""); |
| 169 | |
| 170 | // Create a new context for this run (preserve original flags but reset tasks/results) |
| 171 | const runCtx: CmdRunContext = { |
| 172 | ...ctx, |
| 173 | tasks: [], |
| 174 | results: new Map(), |
| 175 | }; |
| 176 | |
| 177 | // Re-run the translation pipeline |
| 178 | await plan(runCtx); |
| 179 | |
| 180 | if (runCtx.tasks.length === 0) { |
| 181 | console.log(chalk.dim("⨠No translation tasks needed")); |
| 182 | } else { |
| 183 | await execute(runCtx); |
| 184 | await renderSummary(runCtx.results); |
| 185 | } |
| 186 | |
| 187 | console.log(chalk.hex(colors.green)("ā Retranslation completed")); |
| 188 | console.log(chalk.dim("š Continuing to watch for changes...\n")); |
| 189 | } catch (error: any) { |
| 190 | console.error(chalk.red(`ā Retranslation failed: ${error.message}`)); |
| 191 | console.log(chalk.dim("š Continuing to watch for changes...\n")); |
| 192 | } finally { |
| 193 | state.isRunning = false; |
| 194 | } |
| 195 | } |
no test coverage detected