Skip to content

Commit

Permalink
tape: Auto-convert config
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorgalvao committed Sep 7, 2024
1 parent 9c01492 commit 971ca20
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tape
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ require 'tmpdir'
Script_path = Pathname.new($PROGRAM_NAME).expand_path
Script_name = Script_path.basename

# If YAML config exists, convert to JSON
require 'yaml'

if Pathname.new("#{ENV['HOME']}/.config/tape/config.yaml").exist?
Old_conf = YAML.load_file(Pathname.new("#{ENV['HOME']}/.config/tape/config.yaml"))
Old_conf['exclude'] = Old_conf['exclude'] || []
Old_conf['include'] = Old_conf['include'] || []

Pathname.new("#{ENV['HOME']}/.config/tape/config.json").write(JSON.pretty_generate(Old_conf))
Pathname.new("#{ENV['HOME']}/.config/tape/config.yaml").delete
Pathname.new("#{ENV['HOME']}/.config/tape/Definitions").rmtree
end

# Check for minimum ruby version
abort "#{Script_name} requires Ruby 2.7 or higher" if RUBY_VERSION.to_f < 2.7

Expand Down

0 comments on commit 971ca20

Please sign in to comment.