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 985f96e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/stimulus_reflex/sanity_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
class StimulusReflex::SanityChecker
JSON_VERSION_FORMAT = /(\d+\.\d+\.\d+.*)"/

def self.check!
return if StimulusReflex.config.on_failed_sanity_checks == :ignore
class << self
def check!
return if StimulusReflex.config.on_failed_sanity_checks == :ignore
return if called_by_generate_command?

instance = new
instance.check_caching_enabled
instance.check_javascript_package_version
end

private

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

instance = new
instance.check_caching_enabled
instance.check_javascript_package_version
end

def check_caching_enabled
Expand Down

0 comments on commit 985f96e

Please sign in to comment.