Skip to content
← Public packages

@kentcdodds/codemod-runner

Run codemods over your own saved packages: scan, dry-run with real publish checks and diffs, apply, and revert.

src/scan.ts

24 lines · 783 B · TypeScript
import { requireCodemod, runStep, type StepInput } from './step.ts'
import { scanPackage } from './process-package.ts'

/**
 * Scans your packages with a codemod's `detect` and reports which ones need
 * it. Read-only. Paged: keep calling with the returned runId + cursor until
 * nextCursor is null. Default page is 1 package (max 2) so a mid-size
 * tree can finish inside the ~90s export sandbox; per-file
 * repo_read_file RPCs dominate that budget.
 */
export default async function scan(input: StepInput = {}) {
	requireCodemod(input)
	return await runStep({
		mode: 'scan',
		step: input,
		defaults: { limit: 1, max: 2 },
		processPackage: async (_run, pkg) =>
			await scanPackage({
				pkg,
				codemod: input.codemod!,
				detectPattern: input.detectPattern,
			}),
	})
}