maxmcd / webtty

Share a terminal session over WebRTC
https://maxmcd.github.io/webtty/
MIT License
2.71k stars 143 forks source link

Azure pipelines truncates connection data #43

Closed davej closed 1 year ago

davej commented 1 year ago

Webtty is awesome. Thank you! I'm trying to use it with Azure Pipelines but unfortunately, the connection data string is truncated in the logs. Is it possible to add a parameter to wrap the output? Or perhaps you have a suggestion about a different way to solve this? Usually, there is a "view raw log" option in Azure Pipelines but that option is not visible because the task (./webtty -o -ni) is still running.

If I can cancel the pipeline then I can see the entire string but that is not useful because the host connection has now closed.

CleanShot 2022-10-25 at 3 08 02@2x
davej commented 1 year ago

Managed to get this working by using a node script on the host machine that wraps the output:

const { spawn } = require("node:child_process");

const command = spawn("./webtty", ["-o", "-ni"]);

// wrap input string to 80 characters in length
function wrapTo80Chars(str) {
  let result = "";
  for (let i = 0; i < str.length; i += 80) {
    result += str.slice(i, i + 80) + "\r";
  }
  return result;
}

// the `data` event is fired every time data is
// output from the command
command.stdout.on("data", (output) => {
  // the output data is captured and printed in the callback
  console.log(wrapTo40Chars(output.toString()));
});