Skip to content

Conversation

@blsmth
Copy link
Contributor

@blsmth blsmth commented Jul 22, 2025

Summary

  • Extract helper functions to reduce cyclomatic complexity of watchBuildPhase function
  • Improve code readability and maintainability by breaking down complex conditional logic
  • Add proper error handling for pre-build phase failures with log display

Changes

  • Extract isPreBuildPhase() helper to check for pre-build phases
  • Extract isBuildFailed() helper to check build failure status
  • Extract handlePreBuildPhaseFailure() to handle failed pre-build phases with log display
  • Extract startBuildLogTailing() to manage build log streaming
  • Extract updatePreBuildSpinner() to update spinner status for pre-build phases
  • Refactor main logic using switch statement for better readability

This refactoring maintains all existing functionality while making the code more maintainable and easier to understand.

blsmth added 2 commits July 21, 2025 22:43
Fixes #95. When builds fail during prebuild phases (INSTALL, PRE_BUILD, etc.),
users now see the relevant error logs instead of just a spinner. This helps
users understand failures like malformed app.json or apppack.toml files.

The implementation checks CodeBuild status (FAILED, STOPPED, TIMED_OUT) during
prebuild phases and streams logs when failures are detected. This preserves
existing UX for successful builds while providing error visibility for failures.
Extract helper functions to reduce cyclomatic complexity from 21 to improve
maintainability:

- isPreBuildPhase(): Check if phase is a prebuild phase
- isBuildFailed(): Check if CodeBuild status indicates failure
- handlePreBuildPhaseFailure(): Handle prebuild phase failures and show logs
- startBuildLogTailing(): Start log tailing for BUILD phase
- updatePreBuildSpinner(): Update spinner for prebuild phases

Replaced complex if-else chain with cleaner switch statement for better readability.
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