Created
May 23, 2012 07:29
-
-
Save vrinek/2773707 to your computer and use it in GitHub Desktop.
Add encoding line to all spec files
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
| enc = '# -*- encoding : utf-8 -*-' | |
| `git ls-files -- spec | xargs head -1 | grep -v encoding`. | |
| split("\n\n"). | |
| reject{|l| l !~ /\n/}. | |
| map{|l| l.split("\n").first}. | |
| map{|f| f[/^==> (.*) <==$/, 1]}. | |
| each{|f| | |
| system "echo '#{enc}' > tempfile && cat #{f} >> tempfile && mv tempfile #{f}" | |
| } |
Author
@alup yeah, but we need to reject first the files that already have the encoding header.
@vrinek I mean use it in the last each block.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Better use this for bash command: