MCPcopy Create free account
hub / github.com/gnmyt/Nexterm / getScriptCommands

Function getScriptCommands

server/utils/scriptUtils.js:55–69  ·  view source on GitHub ↗
(b64)

Source from the content-addressed store, hash-verified

53};
54
55const getScriptCommands = (b64) => {
56 const CHUNK_SIZE = 2000;
57 const commands = [];
58
59 commands.push(`_nts=$(mktemp) && _ntb=$(mktemp)`);
60
61 for (let i = 0; i < b64.length; i += CHUNK_SIZE) {
62 const chunk = b64.slice(i, i + CHUNK_SIZE);
63 commands.push(`printf '%s' '${chunk}' >> "$_ntb"`);
64 }
65
66 commands.push(`base64 -d < "$_ntb" > "$_nts" && rm -f "$_ntb" && chmod +x "$_nts" && echo "NEXTERM_READY" && "$_nts"; _exit=$?; rm -f "$_nts"; echo "NEXTERM_END:$_exit"`);
67
68 return commands;
69};
70
71const stripAnsi = (s) => s.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
72

Callers 1

startMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected