Skip to content

Instantly share code, notes, and snippets.

@wagenet
Created August 21, 2017 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wagenet/16db15b72d2c64c603198814facda35b to your computer and use it in GitHub Desktop.
Save wagenet/16db15b72d2c64c603198814facda35b to your computer and use it in GitHub Desktop.
require 'json'
output = `yarn outdated --json`
json = JSON.parse(output)
items = if json['type'] == 'table'
keys = json['data']['head']
json['data']['body'].map do |row|
Hash[*row.map.with_index{|v,i| [keys[i], v] }.flatten]
end
else
raise "Can't parse output"
end
skipped, outdated = items.partition{|i| (i['Latest'].include?('-') && !i['Current'].include?('-')) || i['Latest'] == 'exotic' }
puts "Skipped:"
skipped.each do |s|
puts " #{s['Package']}: #{s['Current']} (#{s['Latest']})"
end
puts "\nOutdated:"
outdated.each do |s|
puts " #{s['Package']}: #{s['Current']} (#{s['Latest']})"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment