You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve pack generator robustness and error handling
Based on code review feedback, this commit addresses several critical issues:
1. **Better Bundler context detection**: Now checks ENV['BUNDLE_GEMFILE']
for more robust detection of meaningful Bundler contexts
2. **Enhanced Rails availability checking**: Safely verifies Rails.application
can actually load tasks, with proper error handling
3. **Consistent error handling**: Errors are always written to stderr,
even in silent mode. Backtrace included when DEBUG env var is set
4. **Reduced code complexity**: Refactored run_rake_task_directly into
smaller, focused methods (load_rake_tasks, prepare_rake_task,
capture_output, handle_rake_error) to satisfy RuboCop complexity checks
5. **Maintained test compatibility**: Tests continue to pass because the
code properly falls back to bundle exec in test environment where
BUNDLE_GEMFILE is not set
These changes ensure:
- Tests work correctly (they mock system calls which are used in test env)
- Production bin/dev usage is optimized (direct Rake execution when safe)
- Error messages are never silently swallowed
- More robust detection of execution context
0 commit comments