提交 42e17965 authored 作者: Will Chen's avatar Will Chen

Clean up ANSI escape codes from stdout/stderr (interfered with port detection)

上级 26fb5c8d
...@@ -35,7 +35,7 @@ import { Worker } from "worker_threads"; ...@@ -35,7 +35,7 @@ import { Worker } from "worker_threads";
import fixPath from "fix-path"; import fixPath from "fix-path";
import { getGitAuthor } from "../utils/git_author"; import { getGitAuthor } from "../utils/git_author";
import killPort from "kill-port"; import killPort from "kill-port";
import util from "util";
// Needed, otherwise electron in MacOS/Linux will not be able // Needed, otherwise electron in MacOS/Linux will not be able
// to find "npm". // to find "npm".
fixPath(); fixPath();
...@@ -171,24 +171,22 @@ async function executeAppLocalNode({ ...@@ -171,24 +171,22 @@ async function executeAppLocalNode({
// Log output // Log output
process.stdout?.on("data", (data) => { process.stdout?.on("data", (data) => {
console.log( const message = util.stripVTControlCharacters(data.toString());
`App ${appId} (PID: ${process.pid}) stdout: ${data.toString().trim()}` console.log(`App ${appId} (PID: ${process.pid}) stdout: ${message}`);
);
event.sender.send("app:output", { event.sender.send("app:output", {
type: "stdout", type: "stdout",
message: data.toString().trim(), message,
appId: appId, appId,
}); });
}); });
process.stderr?.on("data", (data) => { process.stderr?.on("data", (data) => {
console.error( const message = util.stripVTControlCharacters(data.toString());
`App ${appId} (PID: ${process.pid}) stderr: ${data.toString().trim()}` console.error(`App ${appId} (PID: ${process.pid}) stderr: ${message}`);
);
event.sender.send("app:output", { event.sender.send("app:output", {
type: "stderr", type: "stderr",
message: data.toString().trim(), message,
appId: appId, appId,
}); });
}); });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论