Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env ruby
require 'pathname'
code_files = ARGV
code_files.each do |file|
file = Pathname(file)
contents = file.read
contents.gsub!(/(^#import .*\n)+/) do |imports|
imports = imports.split("\n")
imports.sort.uniq.join("\n") << "\n"
end
file.open('w') { |f| f.write contents }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment