Skip to content

Commit 402579c

Browse files
committed
Updates bin/jslint for different js interpreters
1 parent 17e1eda commit 402579c

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

bin/jslint

+28-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
target = File.expand_path(ARGV.first)
44

5+
# Cross-platform way of finding an executable in the $PATH.
6+
#
7+
# which('ruby') #=> /usr/bin/ruby
8+
def which(cmd)
9+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
10+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
11+
exts.each { |ext|
12+
exe = "#{path}/#{cmd}#{ext}"
13+
return exe if File.executable? exe
14+
}
15+
end
16+
return nil
17+
end
18+
519
if RUBY_PLATFORM =~ /win32/i
620
js_cmd = 'cscript'
721
runjslint_ext = 'wsf'
@@ -10,11 +24,23 @@ else
1024
if ENV['JS_CMD']
1125
js_cmd = ENV['JS_CMD']
1226
else
13-
js_cmd = 'js'
27+
js_cmd = ['node', 'nodejs', 'js'].find { |ex| which ex }
28+
end
29+
30+
if !js_cmd and File.exist?('/System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc')
31+
js_cmd = '/System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc'
1432
end
33+
1534
runjslint_ext = 'js'
35+
1636
plugin_path = File.join(ENV['HOME'], '.vim')
17-
# check for pathogen
37+
end
38+
39+
# check for pathogen
40+
pathogen_path = File.join(plugin_path, 'bundle', 'jslint.vim')
41+
if File.exist? pathogen_path
42+
plugin_path = pathogen_path
43+
else
1844
pathogen_path = File.join(plugin_path, 'bundle', 'jslint')
1945
plugin_path = pathogen_path if File.exist?(pathogen_path)
2046
end

0 commit comments

Comments
 (0)