Sha256: dbf6771cb054155e89d44b76780eaf2bbbc5e9f71a3b7737f44aa6b5131a8877

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require File.expand_path('../../lib/jslint', __FILE__)

config_file = File.expand_path('config/jslint.yml')
if File.exist? config_file
  config = YAML.load_file(config_file)['jslint']

  options = config['options'] || {}
  predefined = config['predefined'] || []
  options['predef'] = predefined.map { |defs| defs.split(',') }.flatten.map(&:strip) unless predefined.empty?

  options = config['options'].map do |option, value|
    option = option.to_s.strip
    case value
    when true
      "--#{option}"
    when false
      "--no-#{option}"
    else
      "--#{option}=\"#{value.to_json}\""
    end
  end
else
  file_name = ARGV.pop
  options = ARGV.dup
  ARGV.clear
  ARGV.push(file_name)
end

command =  []
if `which node`.empty?
  command << ['java', '-jar', Jslint::RhinoJar]
  command << ['-f', Jslint::Scripts[:json2]]
  command << ['-f', Jslint::Scripts[:jslint]]
  command << Jslint::Scripts[:rhino]
else
  command << ['node']
  command << Jslint::Scripts[:node]
end
command << [ options, ARGV.first]
command = command.flatten.join(' ')
exec command

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jslint-1.1.3 bin/jslint
jslint-1.1.2 bin/jslint