mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Attempt to fix traking stdout
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
41d1f80d07
commit
62f89bdaf4
@ -22,8 +22,7 @@ export const appPaths: Partial<Record<NodeJS.Platform, string>> = {
|
|||||||
async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promise<Page> {
|
async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promise<Page> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const cleanup = disposer();
|
const cleanup = disposer();
|
||||||
const stdoutBuffer = Buffer.from("");
|
let stdoutBuf = "";
|
||||||
const stdoutStream = new Writable(stdoutBuffer);
|
|
||||||
|
|
||||||
const handler = (page: Page) => {
|
const handler = (page: Page) => {
|
||||||
console.log(`Page opened: ${page.url()}`);
|
console.log(`Page opened: ${page.url()}`);
|
||||||
@ -37,12 +36,18 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis
|
|||||||
app.addListener("window", handler);
|
app.addListener("window", handler);
|
||||||
cleanup.push(() => app.removeListener("window", handler));
|
cleanup.push(() => app.removeListener("window", handler));
|
||||||
|
|
||||||
app.process().stdout?.pipe(stdoutStream);
|
const { stdout } = app.process();
|
||||||
cleanup.push(() => app.process().stdout?.unpipe(stdoutStream));
|
|
||||||
|
if (stdout) {
|
||||||
|
const onData = (chunk: any) => stdoutBuf += chunk.toString();
|
||||||
|
|
||||||
|
stdout.on("data", onData);
|
||||||
|
cleanup.push(() => stdout.off("data", onData));
|
||||||
|
}
|
||||||
|
|
||||||
const timeoutId = setTimeout(() => {
|
const timeoutId = setTimeout(() => {
|
||||||
cleanup();
|
cleanup();
|
||||||
console.log(stdoutBuffer.toString("utf8"));
|
console.log(stdoutBuf);
|
||||||
reject(new Error(`Lens did not open the main window within ${timeout}ms`));
|
reject(new Error(`Lens did not open the main window within ${timeout}ms`));
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user