Skip to content

Commit

Permalink
Do not run sanity check on rails generate stimulus_reflex:config
Browse files Browse the repository at this point in the history
If a sanity check fails, the user gets a hint to create the configuration file with
`rails generate stimulus_reflex:config`, however this command will also fail because it
will also run the sanity check. Therefore we have to bypass the sanity check if
the caller is a `generate_command`.
  • Loading branch information
RolandStuder committed Nov 13, 2020
1 parent 1dcf37e commit 147a28f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/stimulus_reflex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
module StimulusReflex
class Engine < Rails::Engine
initializer "stimulus_reflex.sanity_check" do
SanityChecker.check!
SanityChecker.check! unless called_by_generate_command?
end

private

def called_by_generate_command?
caller.any? { |call| call.match("generate_command") }
end
end
end

0 comments on commit 147a28f

Please sign in to comment.