1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00
alacritty/scripts/migrate_ref_tests.rb

22 lines
461 B
Ruby
Raw Normal View History

#!/usr/bin/env ruby
require 'json'
Dir.glob('./tests/ref/**/grid.json').each do |path|
# Read contents
s = File.open(path) { |f| f.read }
# Parse
grid = JSON.parse(s)
# Check if it's already migrated / make this migration idempotent
next if grid['raw'][0][0].is_a? Array
# Transform
grid['raw'].reverse!
grid['raw'] = [grid['raw'], 0, grid['lines'] - 1]
# Write updated grid
File.open(path, 'w') { |f| f << JSON.generate(grid) }
end