PERF: Speed up JSHint tests by using local buffers instead of AJAX

requests.
This commit is contained in:
Robin Ward
2014-07-22 14:13:13 -04:00
parent 386b6213a5
commit 4c51258526
4 changed files with 44 additions and 6 deletions

View File

@ -23,7 +23,17 @@ class DiscourseIIFE < Sprockets::Processor
return data if path =~ /\.shbrs/
return data if path =~ /\.hbrs/
"(function () {\n\nvar $ = window.jQuery;\n// IIFE Wrapped Content Begins:\n\n#{data}\n\n// IIFE Wrapped Content Ends\n\n })(this);"
res = "(function () {\n\nvar $ = window.jQuery;\n// IIFE Wrapped Content Begins:\n\n#{data}\n\n// IIFE Wrapped Content Ends\n\n })(this);"
# Include JS code for JSHint
unless Rails.env.production?
req_path = path.sub(Rails.root.to_s, '')
.sub("/app/assets/javascripts", "")
.sub("/test/javascripts", "")
res << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['/assets#{req_path}'] = #{data.to_json};\n"
end
res
end
end