Skip to content

Commit 8d5f1a9

Browse files
committed
Detect of phlex-rails is installed before trying to install it
1 parent eaab209 commit 8d5f1a9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/generators/superform/install/install_generator.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class Superform::InstallGenerator < Rails::Generators::Base
44
APPLICATION_CONFIGURATION_PATH = Rails.root.join("config/application.rb")
55

66
def install_phlex_rails
7+
return if gem_in_bundle? "phlex-rails"
8+
79
gem "phlex-rails"
810
generate "phlex:install"
911
end
@@ -21,4 +23,9 @@ def autoload_components
2123
def create_application_form
2224
template "application_form.rb", Rails.root.join("app/views/forms/application_form.rb")
2325
end
26+
27+
private
28+
def gem_in_bundle?(gem_name)
29+
Bundler.load.specs.any? { |spec| spec.name == gem_name }
30+
end
2431
end

0 commit comments

Comments
 (0)