diff --git a/Rakefile b/Rakefile index ce36697da..7629fe92b 100644 --- a/Rakefile +++ b/Rakefile @@ -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" @@ -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