discourse/lib/tasks/svg_icons.rake
Loïc Guitaut f7c57fbc19 DEV: Enable unless cops
We discussed the use of `unless` internally and decided to enforce
available rules from rubocop to restrict its most problematic uses.
2023-02-21 10:30:48 +01:00

35 lines
732 B
Ruby

# frozen_string_literal: true
def vendor_svgs
"#{Rails.root}/vendor/assets/svg-icons"
end
def library_src
"#{Rails.root}/node_modules"
end
task "svgicons:update" do
yarn = system("yarn install")
abort('Unable to run "yarn install"') unless yarn
dependencies = [{ source: "@fortawesome/fontawesome-free/sprites", destination: "fontawesome" }]
start = Time.now
dependencies.each do |f|
src = "#{library_src}/#{f[:source]}/."
if f[:destination]
filename = f[:destination]
else
filename = f[:source].split("/").last
end
dest = "#{vendor_svgs}/#{filename}"
FileUtils.cp_r(src, dest)
end
STDERR.puts "Completed copying dependencies: #{(Time.now - start).round(2)} secs"
end