Created
January 31, 2010 01:54
-
-
Save robertsosinski/290837 to your computer and use it in GitHub Desktop.
JSLint Rake Task
This file contains 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
desc "Checks the JavaScript files with JSLint" | |
task :jslint do | |
failed_files = [] | |
skipped_files = ["jquery-1.4.js", "jquery-json-2.1.js"] | |
rhino_path = File.join(RAILS_ROOT, "vendor", "jslint", "js.jar") | |
jslint_path = File.join(RAILS_ROOT, "vendor", "jslint", "jslint.js") | |
Dir['public/**/*.js'].reject{|path| skipped_files.include?(path.match(/.*\/(.*)/)[1])}.each do |name| | |
cmd = "java -jar #{rhino_path} #{jslint_path} #{name}" | |
results = %x{#{cmd}} | |
unless results =~ /^jslint: No problems found in/ | |
puts "#{name}:" | |
puts results | |
failed_files << name | |
end | |
end | |
if failed_files.size > 0 | |
exit 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment