MCPcopy
hub / github.com/ternjs/tern_for_vim / tern_startServer

Function tern_startServer

script/tern.py:72–98  ·  view source on GitHub ↗
(project)

Source from the content-addressed store, hash-verified

70 return (tern_startServer(project), False)
71
72def tern_startServer(project):
73 if time.time() - project.last_failed < 30: return None
74
75 win = platform.system() == "Windows"
76 env = None
77 if platform.system() == "Darwin":
78 env = os.environ.copy()
79 env["PATH"] += ":/usr/local/bin"
80 proc = subprocess.Popen(vim.eval("g:tern#command") + vim.eval("g:tern#arguments"),
81 cwd=project.dir, env=env,
82 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
83 stderr=subprocess.STDOUT, shell=win)
84 output = ""
85 while True:
86 line = proc.stdout.readline()
87 if not line:
88 tern_displayError("Failed to start server" + (output and ":\n" + output))
89 project.last_failed = time.time()
90 return None
91 match = re.match("Listening on port (\\d+)", line)
92 if match:
93 port = int(match.group(1))
94 project.port = port
95 project.proc = proc
96 return port
97 else:
98 output += line
99
100def tern_killServer(project):
101 if project.proc is None: return

Callers 1

tern_findServerFunction · 0.85

Calls 1

tern_displayErrorFunction · 0.85

Tested by

no test coverage detected