5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-18 12:52:21 +00:00

fix: instalar las gemas cuando sea necesario #12755

si se modificó el gemfile queremos volver a instalarlas también
This commit is contained in:
f 2023-03-27 11:45:23 -03:00
parent 3e6288fefe
commit 6b759c92ce

View file

@ -553,10 +553,33 @@ class Site < ApplicationRecord
Dir.chdir path, &block
end
# Instala las gemas cuando es necesario:
#
# * El sitio existe
# * No están instaladas
# * El archivo Gemfile se modificó
# * El archivo Gemfile.lock se modificó
def install_gems
return unless persisted?
return if Rails.root.join('_storage', 'gems', name).directory?
deploys.find_by_type('DeployLocal').send(:bundle)
if !gem_dir? || gemfile_updated? || gemfile_lock_updated?
deploys.find_by_type('DeployLocal').send(:bundle)
touch
end
end
# Detecta si el repositorio de gemas existe
def gem_dir?
Rails.root.join('_storage', 'gems', name).directory?
end
# Detecta si el Gemfile fue modificado
def gemfile_updated?
updated_at > File.mtime(File.join(path, 'Gemfile'))
end
# Detecta si el Gemfile.lock fue modificado
def gemfile_lock_updated?
updated_at > File.mtime(File.join(path, 'Gemfile.lock'))
end
end