-
Notifications
You must be signed in to change notification settings - Fork 5
/
node_dependents_editor_backend.py
58 lines (43 loc) · 1.7 KB
/
node_dependents_editor_backend.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import sublime
import traceback
is_ST2 = sys.version_info < (3,)
if is_ST2:
from lib.show_error import show_error
from node_bridge import node_bridge
from lib.printer import p
from lib.project_settings import get_project_settings
else:
from .lib.show_error import show_error
from .node_bridge import node_bridge
from .lib.printer import p
from .lib.project_settings import get_project_settings
def backend(options):
args = []
if 'filename' in options:
args.append('--filename=' + options['filename'])
if is_ST2:
editor = 'ST2'
else:
editor = 'ST3'
args.append('--editor=' + editor)
if 'command' in options:
args.append('--' + options['command'])
# TODO: Deprecate when JumpToDependency combines with JumpToDefinition
if 'lookup_position' in options:
args.append('--lookup-position=' + str(options['lookup_position']))
if 'click_position' in options:
args.append('--click-position=' + str(options['click_position']))
if 'path' in options:
args.append(options['path'])
try:
node_path = get_project_settings(options['filename']).get('node_path')
p('node_path from settings: ', node_path)
# TODO: It's not great to hardcode the Package name here but __file__ isn't consistent between Python 2 and 3
bin_path = sublime.packages_path() + '/Dependents/node_modules/dependents-editor-backend/bin/cli.js'
p('bin path', bin_path)
return node_bridge(bin_path, args, node_path)
except Exception as e:
traceback.print_exc()
show_error('An error occurred. Please file an issue with the following:\n\n' + str(e), True)
return ''