Skip to content

Instantly share code, notes, and snippets.

@pocke
Created July 23, 2021 08:42
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 pocke/f60bd38b6586c7d981af9b3ec3bde6f3 to your computer and use it in GitHub Desktop.
Save pocke/f60bd38b6586c7d981af9b3ec3bde6f3 to your computer and use it in GitHub Desktop.
# Print gems that contains `test_files` in gemspec with disk consumed order.
#
# Usage:
# bundle install --path /path/to/somewhere
# cd /path/to/somewhere/ruby/VERSION/gems
# ruby THIS_SCRIPT.rb
#
# Pro tip: The following links are useful when you open a PR to remove test_files.
# * https://github.com/rubygems/guides/issues/90
# * https://github.com/rubygems/bundler/pull/3207
files = `grep test_files */*.gemspec`.split("\n").map { _1[/([^:]+):/, 1] }.uniq
du = `du * --summarize --bytes | sort -n`.split("\n").map { _1[/([^\s]+)$/, 1] }.reverse
pp files.sort_by { |f| du.find_index { |du_item| f.include? du_item } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment