Skip to content

Commit

Permalink
node is the preferred Javascript engine, JSC_PATH is not exported
Browse files Browse the repository at this point in the history
  • Loading branch information
aparajita committed Apr 9, 2012
1 parent 67bbdc6 commit ba779bb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"1.5.3": "messages/1.5.3.txt",
"1.5.4": "messages/1.5.4.txt",
"1.5.5": "messages/1.5.5.txt",
"1.5.6": "messages/1.5.6.txt"
"1.5.6": "messages/1.5.6.txt",
"1.5.7": "messages/1.5.7.txt"
}
10 changes: 10 additions & 0 deletions messages/1.5.7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SublimeLinter 1.5.7 changelog

CHANGES/FIXES

- node.js is the preferred Javascript engine on Mac OS X and will be used if it is installed.
JavaScriptCore does not handle non-ASCII text correctly and you should install node.js
if possible.

- If you imported BaseLinter.JSC_PATH, please change your linter to use the self.jsc_path()
method instead. JSC_PATH should no longer be considered public.
6 changes: 3 additions & 3 deletions package_control.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"description": "Inline lint highlighting for the Sublime Text 2 editor",
"author": "Kronuz, Aparajita Fishman, Jake Swartwood",
"homepage": "http://github.com/Kronuz/SublimeLinter",
"last_modified": "2012-03-24 18:27:31",
"last_modified": "2012-04-08 18:27:31",
"platforms": {
"*": [
{
"version": "1.5.6",
"url": "https://nodeload.github.com/Kronuz/SublimeLinter/zipball/v1.5.6"
"version": "1.5.7",
"url": "https://nodeload.github.com/Kronuz/SublimeLinter/zipball/v1.5.7"
}
]
}
Expand Down
33 changes: 22 additions & 11 deletions sublimelinter/modules/base_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
if not os.path.exists(TEMPFILES_DIR):
os.mkdir(TEMPFILES_DIR)

JSC_PATH = '/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc'


class BaseLinter(object):
'''A base class for linters. Your linter module needs to do the following:
Expand All @@ -84,6 +82,11 @@ class BaseLinter(object):
If you do subclass and override __init__, be sure to call super(MyLinter, self).__init__(config).
'''

JSC_PATH = '/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc'

JAVASCRIPT_ENGINES = ['node', 'jsc']
JAVASCRIPT_ENGINE_NAMES = {'node': 'node.js', 'jsc': 'JavaScriptCore'}

def __init__(self, config):
self.language = config['language']
self.enabled = False
Expand Down Expand Up @@ -302,14 +305,22 @@ def execute_get_output(self, args):
def jsc_path(self):
'''Return the path to JavaScriptCore. Use this method in case the path
has to be dynamically calculated in the future.'''
return JSC_PATH
return self.JSC_PATH

def get_javascript_engine(self, view):
if os.path.exists(self.jsc_path()):
return (True, self.jsc_path(), 'using JavaScriptCore')
try:
path = self.get_mapped_executable(view, 'node')
subprocess.call([path, '-v'], startupinfo=self.get_startupinfo())
return (True, path, '')
except OSError:
return (False, '', 'JavaScriptCore or node.js is required')
for engine in self.JAVASCRIPT_ENGINES:
if engine == 'node':
try:
path = self.get_mapped_executable(view, 'node')
subprocess.call([path, '-v'], startupinfo=self.get_startupinfo())
return (True, path, '')
except OSError:
pass

elif engine == 'jsc':
if os.path.exists(self.jsc_path()):
return (True, self.jsc_path(), 'using {0}'.format(self.JAVASCRIPT_ENGINE_NAMES[engine]))

# Didn't find an engine, tell the user
engine_list = ', '.join(self.JAVASCRIPT_ENGINE_NAMES.values())
return (False, '', 'One of the following Javascript engines must be installed: ' + engine_list)

0 comments on commit ba779bb

Please sign in to comment.