MCPcopy
hub / github.com/lingodotdev/lingo.dev / handleFileChange

Function handleFileChange

packages/cli/src/cli/cmd/run/watch.ts:128–155  ·  view source on GitHub ↗
(
  filePath: string,
  state: WatchState,
  ctx: CmdRunContext,
)

Source from the content-addressed store, hash-verified

126}
127
128function handleFileChange(
129 filePath: string,
130 state: WatchState,
131 ctx: CmdRunContext,
132) {
133 const debounceDelay = ctx.flags.debounce || 5000; // Use configured debounce or 5s default
134
135 state.pendingChanges.add(filePath);
136
137 console.log(chalk.dim(`📝 File changed: ${filePath}`));
138
139 // Clear existing debounce timer
140 if (state.debounceTimer) {
141 clearTimeout(state.debounceTimer);
142 }
143
144 // Set new debounce timer
145 state.debounceTimer = setTimeout(async () => {
146 if (state.isRunning) {
147 console.log(
148 chalk.yellow("⏳ Translation already in progress, skipping..."),
149 );
150 return;
151 }
152
153 await triggerRetranslation(state, ctx);
154 }, debounceDelay);
155}
156
157async function triggerRetranslation(state: WatchState, ctx: CmdRunContext) {
158 if (state.isRunning) return;

Callers 1

watchFunction · 0.85

Calls 2

triggerRetranslationFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected