Skip to content

Commit

Permalink
have rake test fail on trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Apr 13, 2012
1 parent 753e801 commit 41a00bb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ task(:clean) { rm_rf 'dist' }
desc "Run tests with PhantomJS"
task :test do
sh 'script/test'
Rake::Task[:check_whitespace].invoke
end

desc "Strip trailing whitespace and ensure each file ends with a newline"
Expand All @@ -96,6 +97,16 @@ task :whitespace do
end
end

desc "Checks for trailing whitespace in source files and tests"
task :check_whitespace do
flunked = false
flunk = lambda {|file, num| flunked = true; puts "#{file}:#{num}" }
Dir['{src,test,examples}/**/*.{js,html}'].each do |file|
File.open(file, 'r') {|f| f.each_with_index {|ln, num| flunk.call(file, num + 1) if ln.chomp =~ /\s+$/ } }
end
fail if flunked
end

desc "Generate docco documentation from source files"
task :docco do
verbose false do
Expand Down

0 comments on commit 41a00bb

Please sign in to comment.