Skip to content

Commit 067a8fe

Browse files
ihabadhamclaude
andcommitted
fix: Always run final install to prevent edge cases
Address CodeRabbit suggestion #1: - Remove conditional logic that could skip final install - Always run install_js_dependencies to ensure packages are properly installed - Update test to reflect the improved behavior - Prevents scenarios where no install runs when package_json methods fail 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 04f2c49 commit 067a8fe

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

lib/generators/react_on_rails/js_dependency_manager.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def setup_js_dependencies
5454
@added_dependencies_to_package_json ||= false
5555
@ran_direct_installs ||= false
5656
add_js_dependencies
57-
# Only run final install if package_json gem was used and no direct installs ran
58-
install_js_dependencies if @added_dependencies_to_package_json && !@ran_direct_installs
57+
install_js_dependencies
5958
end
6059

6160
def add_js_dependencies
@@ -76,17 +75,15 @@ def add_react_on_rails_package
7675
"react-on-rails"
7776
end
7877

79-
packages_array = [react_on_rails_pkg]
80-
8178
puts "Installing React on Rails package..."
82-
if add_js_dependencies_batch(packages_array)
79+
if add_js_dependency(react_on_rails_pkg)
8380
@added_dependencies_to_package_json = true
8481
else
8582
# Fallback to direct npm install
8683
puts "Using direct npm commands as fallback"
87-
success = system("npm", "install", *packages_array)
84+
success = system("npm", "install", react_on_rails_pkg)
8885
@ran_direct_installs = true if success
89-
handle_npm_failure("react-on-rails package", packages_array) unless success
86+
handle_npm_failure("react-on-rails package", [react_on_rails_pkg]) unless success
9087
end
9188
end
9289

spec/react_on_rails/generators/message_deduplication_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@
118118
"package.json")).and_return(true)
119119
end
120120

121-
it "does not run the bulk install after direct installs" do
122-
# Expect individual package installs but no bulk install
121+
it "runs individual installs plus final install" do
122+
# Expect individual package installs plus one final bulk install
123123
expect(install_generator).to receive(:system).with("npm", "install", anything).at_least(:once).and_return(true)
124-
expect(install_generator).not_to receive(:system).with("npm", "install")
124+
expect(install_generator).to receive(:system).with("npm", "install").once.and_return(true)
125125

126126
# Run the dependency setup
127127
install_generator.send(:setup_js_dependencies)

0 commit comments

Comments
 (0)