Skip to content

Commit

Permalink
DEV: Add an option to skip a theme update from the themes:install tas…
Browse files Browse the repository at this point in the history
…k. (#12905)

A theme can now specify `skip_update: true` in the yml config for
update allowing for the theme to be installed only if it does not already
exist.
  • Loading branch information
featheredtoast committed Apr 30, 2021
1 parent 7b5f31f commit 656b0ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/services/themes_install_task.rb
Expand Up @@ -2,14 +2,17 @@

class ThemesInstallTask
def self.install(themes)
counts = { installed: 0, updated: 0, errors: 0 }
counts = { installed: 0, updated: 0, errors: 0, skipped: 0 }
log = []
themes.each do |name, val|
installer = new(val)
next if installer.url.nil?

if installer.theme_exists?
if installer.update
if installer.options.fetch(:skip_update, nil)
log << "#{name}: is already installed. Skipping update."
counts[:skipped] += 1
elsif installer.update
log << "#{name}: is already installed. Updating from remote."
counts[:updated] += 1
else
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/themes.rake
Expand Up @@ -45,6 +45,7 @@ task "themes:install" => :environment do |task, args|
puts " Installed: #{counts[:installed]}"
puts " Updated: #{counts[:updated]}"
puts " Errors: #{counts[:errors]}"
puts " Skipped: #{counts[:skipped]}"

if counts[:errors] > 0
exit 1
Expand Down

0 comments on commit 656b0ae

Please sign in to comment.