Skip to content

refactor: extract fix command utilities from src/index.ts to src/utils/fix-runner.ts #437

@sonukapoor

Description

@sonukapoor

Three pure utility functions related to running fix commands are currently defined in src/index.ts but belong in a dedicated module.

Functions to move (all currently in src/index.ts):

  • buildFixCommandParts(packageManager, targets) — builds the ["npm", "install", "pkg@version"] array
  • runInstallCommand(command, args, cwd) — spawns the install process and returns { status, error }
  • commandLabelForPackageManager(packageManager) — returns "npm install", "pnpm add", etc.

What to do:

  1. Create src/utils/fix-runner.ts
  2. Move the three functions into it, adding export to each
  3. Add the necessary imports (node:child_process for spawn, and the relevant types from ../types.js and ../remediation/fix-commands.js)
  4. Update src/index.ts to import them from ./utils/fix-runner.js
  5. Run npm test and npm run build to confirm nothing broke

This is a pure refactor — no logic changes. The functions are self-contained and have no side effects, making this a safe extraction.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions