Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/generators/react_on_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def run_generators
end
ensure
# Always clean up ENV variable, even if generator fails
# CRITICAL: ENV cleanup must come first to ensure it executes even if
# print_generator_messages raises an exception. This prevents ENV pollution
# that could affect subsequent processes.
ENV.delete("REACT_ON_RAILS_SKIP_VALIDATION")
print_generator_messages
end
Expand Down
6 changes: 6 additions & 0 deletions lib/react_on_rails/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class Engine < ::Rails::Engine
# generators concurrently (e.g., in parallel tests), ensure tests run in separate
# processes to avoid ENV variable conflicts.
#
# @example Testing with parallel processes
# # In RSpec configuration:
# config.before(:each) do |example|
# ENV.delete("REACT_ON_RAILS_SKIP_VALIDATION")
# end
#
# @note Manual ENV Setting: While this ENV variable is designed to be set by generators,
# users can manually set it (e.g., `REACT_ON_RAILS_SKIP_VALIDATION=true rails server`)
# to bypass validation. This should only be done temporarily during debugging or
Expand Down
5 changes: 5 additions & 0 deletions spec/react_on_rails/engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ module ReactOnRails
expect(Rails.logger).not_to have_received(:debug)
.with("[React on Rails] Skipping validation during generator runtime")
end

it "short-circuits before checking File.exist?" do
described_class.skip_version_validation?
expect(File).not_to have_received(:exist?)
end
end

context "when package.json is missing" do
Expand Down
Loading