console.log calls per package, returns the counts as a report, and fails CI when there are more than you allow. The run only reads, so it works on a repository with uncommitted changes too. You need Node.js 22.18 or later and Git.
1. The project
packages/api/src/orders.ts
packages/web/src/app.ts
packages/web/src/util.ts
2. The workflow
workflow.ts
- The callback returns how many calls one file has.
- The reducer,
(counts, found, path) => …, folds those numbers into one object per package, starting from{}. The step’s result has it asreduced. A reducer keeps only the running result in memory, so it works on targets with many thousands of files. containing: "console.log"skips files that don’t mention it.- What
mainreturns is the run’s output.fail(message, { output })ends the run asfailed, keeps the report as its output, and makes the CLI exit2. Paramsdeclares the parameters the workflow takes.--param max=5setsmax.
3. Run it
--param max=5 arrives as the number 5. A parameter declared string keeps the same input as text ("5").4. Read the report as JSON
Every run is saved. Read the failed one back, for a CI summary or a dashboard:params, timestamps and durations.)
outputis the report, also for a failed run.exitCodeis the codefail()gave the CLI to exit with.- Each step has its
result, here thereducedcounts, andfiles: how many files it worked on and how many failed.
--format jsonl, the run’s last line, run_finished, carries the same status and output, so a program driving the run doesn’t need a second command.
Use it in CI
The exit code is all CI needs:0 passes, 2 fails the job. See Exit codes and Running in CI and from agents.
fail() takes another code if 2 means something else to you: fail(message, { output, exitCode: 4 }), any code from 1 to 125.