Skip to content

Instantly share code, notes, and snippets.

@dzaporozhets
Forked from NARKOZ/whitespace.rake
Created June 5, 2012 08:06
Show Gist options
  • Save dzaporozhets/2873514 to your computer and use it in GitHub Desktop.
Save dzaporozhets/2873514 to your computer and use it in GitHub Desktop.
Whitespaaaaaaaace! WHITESPAAAAAAAACE!
namespace :whitespace do
desc 'Removes trailing whitespace'
task :cleanup do
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
do sed -i '' 's/ *$//g' "$f";
done}, {:verbose => false}
puts "done"
end
desc 'Converts hard-tabs into two-space soft-tabs'
task :retab do
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
do sed -i '' 's/\t/ /g' "$f";
done}, {:verbose => false}
puts "done"
end
desc 'Remove consecutive blank lines'
task :scrub_gratuitous_newlines do
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
do sed -i '' '/./,/^$/!d' "$f";
done}, {:verbose => false}
puts "done"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment