Read SVG path from the command line

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2025-02-23 12:34:44 -08:00
parent d847d20666
commit 804147caef

View File

@ -5,7 +5,8 @@ require 'nokogiri'
require 'set'
# 1) Process all files passed in from the command line
files = ARGV
svgpath = ARGV[0]
files = ARGV[1..]
# 2) Extract used Feather icons
used_icons = Set.new
@ -27,7 +28,7 @@ end
puts "Found #{used_icons.size} unique icons: #{used_icons.to_a.join(', ')}"
# 3) Load the full feather-sprite.svg as XML
sprite_doc = File.open("feather-sprite.svg", "r:UTF-8") { |f| Nokogiri::XML(f) }
sprite_doc = File.open(svgpath, "r:UTF-8") { |f| Nokogiri::XML(f) }
# 4) Create a new SVG with only the required symbols
new_svg = Nokogiri::XML::Document.new
@ -43,7 +44,7 @@ sprite_doc.css("symbol").each do |symbol_node|
end
# 5) Save the subset sprite
File.open("custom-sprite.svg", "w:UTF-8") do |f|
File.open(svgpath, "w:UTF-8") do |f|
f.write(new_svg.to_xml)
end