Skip to content

Instantly share code, notes, and snippets.

@duckworth
duckworth / fetch_icon.rake
Last active January 8, 2025 11:55
Fetch an iconify icon and save it as a rails partial
namespace :icon do
require "net/http"
require "json"
desc "Fetch an iconify icon and save it as partial `bin/rails icon:fetch ICON=heroicons:light-bulb`"
task fetch: :environment do
icon_name = ENV["ICON"]
if icon_name.nil? || icon_name.strip.empty?
puts "ERROR: Please provide an icon name using the ICON environment variable (e.g., bin/rails icon:fetch ICON=heroicons:light-bulb)"