Skip to content

Commit 8d40028

Browse files
committed
feat(run): add --strict fail-fast mode; add plan.md for implementation plan
1 parent adb1c34 commit 8d40028

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

packages/cli/src/cli/cmd/run/execute.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default async function execute(input: CmdRunContext) {
7777

7878
return task.newListr(workerTasks, {
7979
concurrent: true,
80-
exitOnError: false,
80+
exitOnError: !!ctx.flags.strict,
8181
rendererOptions: {
8282
...commonTaskRendererOptions,
8383
collapseSubtasks: true,
@@ -87,7 +87,7 @@ export default async function execute(input: CmdRunContext) {
8787
},
8888
],
8989
{
90-
exitOnError: false,
90+
exitOnError: !!input.flags.strict,
9191
rendererOptions: commonTaskRendererOptions,
9292
},
9393
).run(input);
@@ -296,6 +296,9 @@ function createWorkerTask(args: {
296296
targetLocale: assignedTask.targetLocale,
297297
} satisfies CmdRunTaskResult;
298298
} catch (error) {
299+
if (args.ctx.flags.strict) {
300+
throw error;
301+
}
299302
return {
300303
status: "error",
301304
error: error as Error,

packages/cli/src/cli/cmd/run/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ export default new Command()
112112
"--sound",
113113
"Play audio feedback when translations complete (success or failure sounds)",
114114
)
115+
.option(
116+
"--strict",
117+
"Stop immediately on first error instead of continuing to process remaining buckets and locales (fail-fast mode)",
118+
)
115119
.action(async (args) => {
116120
let authId: string | null = null;
117121
try {

plan.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Title: Add `--strict` to `run` with fail-fast behavior matching `i18n`
2+
3+
Objective
4+
- Implement a `--strict` flag for the `run` command that stops processing immediately on the first error, mirroring the `i18n` command’s fail-fast behavior.
5+
6+
Scope
7+
- `packages/cli/src/cli/cmd/run/index.ts`
8+
- `packages/cli/src/cli/cmd/run/execute.ts`
9+
- Verification only, no changes required in `packages/cli/src/cli/cmd/run/_types.ts:46`.
10+
11+
Implementation Steps
12+
1) Expose CLI flag in `packages/cli/src/cli/cmd/run/index.ts:60`:
13+
- Add `.option("--strict", "Stop immediately on first error instead of continuing to process remaining buckets and locales (fail-fast mode)")` alongside the other flags.
14+
15+
2) Enforce fail-fast execution in `packages/cli/src/cli/cmd/run/execute.ts`:
16+
- Top-level Listr: set `exitOnError` to `true` when `input.flags.strict` is `true`.
17+
- Worker sub-Listr: set `exitOnError` to `true` when `ctx.flags.strict` is `true`.
18+
- In `createWorkerTask` error handling, rethrow on error when `args.ctx.flags.strict` is `true`; otherwise, return the `{ status: "error", ... }` result so non-strict runs continue.
19+
20+
3) Types validation
21+
- No change required; `packages/cli/src/cli/cmd/run/_types.ts:46` already defines `strict: z.boolean().optional()` and is consumed via `flagsSchema.parse(args)`.
22+
23+
Behavioral Guarantees
24+
- With `--strict`, the first task error aborts the pipeline immediately and returns a non-zero exit code.
25+
- Without `--strict`, the pipeline continues processing remaining tasks and reports a per-task summary including errors and successes.
26+
- Watch mode continues to observe files. Each triggered run honors `--strict` for that run and resumes watching afterward.
27+
28+
Rationale From `i18n` Review
29+
- `packages/cli/src/cli/cmd/i18n.ts:522` and `packages/cli/src/cli/cmd/i18n.ts:548` throw on errors when `flags.strict` is `true` and otherwise continue while tracking errors. The above changes apply the same semantics to the `run` pipeline, which executes tasks concurrently via Listr.
30+

0 commit comments

Comments
 (0)