I'm building an Electron app with React and because i'm spawning terminal shells i want to let the user see the output of the terminal in the React app itself.
What I am currently doing is this:
function TerminalOutput() {
const [terminalOutput, setTerminalOutput] = useState<any[]>([])
useEffect(() => {
window.electron.ipcRenderer.on("project-commands-output", (out) => {
setTerminalOutput((prevTerminalOutput) => [...prevTerminalOutput, out])
})
}, [])
return (
<Box>
{terminalOutput.map((outLine, i) => {
return <p key={i}>{outLine}</p>
})}
</Box>
)
}
And what I'm getting is this:
As you can see the output is filled with codes coming from the library that colorises the text. How can i "parse" this type of output and let the user see the the latter without those codes? Are there any libraries that can help me with this or maybe that can already parse terminal output? Thanks.
