Class: ImportmapCLI::Commands::Json
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ImportmapCLI::Commands::Json
- Defined in:
- lib/importmap_cli/commands/json.rb
Overview
Class that generates importmap in json format
Instance Method Summary collapse
Instance Method Details
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/importmap_cli/commands/json.rb', line 7 def run # ensure importmap.rb exists unless File.exist?("#{ImportmapCLI.current_dir}/config/importmap.rb") puts "[error] #{ImportmapCLI.current_dir}/config/importmap.rb file does not exist" exit 1 end imports = {} importmap_each_pin do |_line, matcher| package, url = matcher.values_at(:package, :url) imports.update(package => url) end puts JSON.pretty_generate({ imports: imports }) end |