Module: Jshint::Cli
- Defined in:
- lib/jshint/cli.rb
Class Method Summary collapse
Class Method Details
.run(reporter_name = :Default, result_file = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jshint/cli.rb', line 3 def self.run(reporter_name = :Default, result_file = nil) 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 result_file Dir.mkdir(File.dirname(result_file)) File.open(result_file, 'w') do |stream| printer.call(stream) end else printer.call($stdout) end linter end |