Created
September 24, 2015 22:48
-
-
Save segiddins/a21864ec1104f2479652 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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