MCPcopy Create free account
hub / github.com/decodecaptcha/Browser-Env / exec

Method exec

jsenv/nodeenv/async_execjs.py:129–142  ·  view source on GitHub ↗

Execute `js` using given `node` executable.

(node: str, js: str)

Source from the content-addressed store, hash-verified

127
128 @staticmethod
129 async def exec(node: str, js: str) -> str:
130 """Execute `js` using given `node` executable."""
131 p = await asyncio.subprocess.create_subprocess_exec(
132 node,
133 stdin=asyncio.subprocess.PIPE,
134 stdout=asyncio.subprocess.PIPE,
135 stderr=asyncio.subprocess.PIPE,
136 executable=which(node),
137 )
138 stdout, stderr = await p.communicate(js.encode())
139 removesuffix = lambda s: s[:-1] if str.endswith(s, "\n") else s
140 if stderr:
141 raise JsRuntimeError(p.returncode or 1, node, removesuffix(stderr.decode()))
142 return removesuffix(stdout.decode())
143
144 def bind(self, expr: Optional[JsExpr] = None):
145 """Return an partial of `.exec`, with `node` set to :obj:`.node`,

Callers

nothing calls this directly

Calls 1

JsRuntimeErrorClass · 0.85

Tested by

no test coverage detected