Skip to content

refactor: extract shared utilities to reduce code duplication#313

Merged
jackwener merged 1 commit intojackwener:mainfrom
shouldnotappearcalm:main
Mar 23, 2026
Merged

refactor: extract shared utilities to reduce code duplication#313
jackwener merged 1 commit intojackwener:mainfrom
shouldnotappearcalm:main

Conversation

@shouldnotappearcalm
Copy link
Copy Markdown
Contributor

@shouldnotappearcalm shouldnotappearcalm commented Mar 23, 2026

Summary

  • Extract getErrorMessage() to errors.ts (previously duplicated in 5 files)
  • Extract DEFAULT_DAEMON_PORT to constants.ts (previously hardcoded in 5 files)

Motivation

These utilities were duplicated across multiple files:

  • getErrorMessage was defined identically in build-manifest.ts, commanderAdapter.ts, discovery.ts, execution.ts, validate.ts
  • 19825 port number was hardcoded in daemon.ts, browser/daemon-client.ts, browser/discover.ts, browser/errors.ts, doctor.ts

Changes

File Change
src/errors.ts Add getErrorMessage() function
src/constants.ts Add DEFAULT_DAEMON_PORT constant
5 files using getErrorMessage Import from errors.ts
5 files using daemon port Import from constants.ts

Benefits

  • Single source of truth for error message extraction
  • Single source of truth for daemon port configuration
  • Easier to maintain and modify in the future
  • No functional changes

@jackwener jackwener closed this Mar 23, 2026
@jackwener jackwener reopened this Mar 23, 2026
…odules

- Add getErrorMessage() to errors.ts (used in 5 files)
- Add DEFAULT_DAEMON_PORT to constants.ts (used in 5 files)
- Reduces code duplication and improves maintainability
@jackwener jackwener merged commit b6a02f8 into jackwener:main Mar 23, 2026
11 checks passed
@jackwener jackwener mentioned this pull request Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants