Created
November 5, 2012 15:47
-
-
Save Andrew8xx8/4017893 to your computer and use it in GitHub Desktop.
Convert indentation and line endings
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 'fileutils' | |
| require 'tempfile' | |
| if ARGV[0] == nil | |
| path = '**' | |
| else | |
| path = File.join(ARGV[0], '**') | |
| end | |
| files = File.join(path, "*.{xml,js,css,tpl}") | |
| Dir.glob(files).each do |file_name| | |
| t_file = Tempfile.new(file_name + '.tmp') | |
| File.open(file_name, 'r') do |f| | |
| f.each_line{|line| t_file.puts line.gsub(/\t/, ' '*4).gsub(/\r\n/, '\n')} | |
| end | |
| FileUtils.mv(t_file.path, file_name) | |
| puts 'Succesful converted: ' + file_name | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment