MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / run_js

Function run_js

tests/scripts/conftest.py:151–166  ·  view source on GitHub ↗

Run an arbitrary JS program under Node and return its last JSON line.

(program: str)

Source from the content-addressed store, hash-verified

149
150
151def run_js(program: str):
152 """Run an arbitrary JS program under Node and return its last JSON line."""
153 result = subprocess.run(
154 ["node", "-"],
155 input=program,
156 capture_output=True,
157 text=True,
158 encoding="utf-8",
159 timeout=30,
160 )
161
162 if result.returncode != 0:
163 raise RuntimeError(f"Node.js exited {result.returncode}:\n{result.stderr}")
164
165 last_line = result.stdout.strip().splitlines()[-1]
166 return json.loads(last_line)

Callers 1

_runFunction · 0.85

Calls 1

runMethod · 0.45

Tested by

no test coverage detected