Skip to content

Instantly share code, notes, and snippets.

@lowjoel
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lowjoel/2916e2fb61a2b2bcbcfe to your computer and use it in GitHub Desktop.
Save lowjoel/2916e2fb61a2b2bcbcfe to your computer and use it in GitHub Desktop.
Running JSHint from the command line without rake
#!/usr/bin/env ruby
# encoding: utf-8
require 'jshint'
require 'jshint/reporters'
reporter_name = ARGV[0] || :Default
file = ARGV[1]
linter = Jshint::Lint.new
linter.lint
reporter = Jshint::Reporters.const_get(reporter_name).new(linter.errors)
printer = lambda do |stream|
stream.puts reporter.report
end
if file
FileUtils.mkpath(File.dirname(file))
File.open(file, 'w') do |stream|
printer.call(stream)
end
else
printer.call($stdout)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment