mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 10:43:40 +00:00
Merge branch 'issue-12755' into 'rails'
fix: instalar las gemas cuando sea necesario #12755 See merge request sutty/sutty!130
This commit is contained in:
commit
b65357cdec
1 changed files with 25 additions and 2 deletions
|
@ -554,10 +554,33 @@ class Site < ApplicationRecord
|
||||||
Dir.chdir path, &block
|
Dir.chdir path, &block
|
||||||
end
|
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
|
def install_gems
|
||||||
return unless persisted?
|
return unless persisted?
|
||||||
return if Rails.root.join('_storage', 'gems', name).directory?
|
|
||||||
|
|
||||||
|
if !gem_dir? || gemfile_updated? || gemfile_lock_updated?
|
||||||
deploys.find_by_type('DeployLocal').send(:bundle)
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue