Skip to content

Instantly share code, notes, and snippets.

@segiddins
Created September 24, 2015 22:48
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save segiddins/a21864ec1104f2479652 to your computer and use it in GitHub Desktop.
#!/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