mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cleanup attemptStart code
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
63b335aa19
commit
dbac067e71
@ -23,7 +23,7 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis
|
|||||||
const cleanup = disposer();
|
const cleanup = disposer();
|
||||||
let stdoutBuf = "";
|
let stdoutBuf = "";
|
||||||
|
|
||||||
const handler = (page: Page) => {
|
const onWindow = (page: Page) => {
|
||||||
console.log(`Page opened: ${page.url()}`);
|
console.log(`Page opened: ${page.url()}`);
|
||||||
|
|
||||||
if (page.url().startsWith("http://localhost")) {
|
if (page.url().startsWith("http://localhost")) {
|
||||||
@ -33,6 +33,9 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
app.on("window", onWindow);
|
||||||
|
cleanup.push(() => app.off("window", onWindow));
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
cleanup();
|
cleanup();
|
||||||
reject(new Error("App has unnexpectedly closed"));
|
reject(new Error("App has unnexpectedly closed"));
|
||||||
@ -41,17 +44,12 @@ async function getMainWindow(app: ElectronApplication, timeout = 50_000): Promis
|
|||||||
app.on("close", onClose);
|
app.on("close", onClose);
|
||||||
cleanup.push(() => app.off("close", onClose));
|
cleanup.push(() => app.off("close", onClose));
|
||||||
|
|
||||||
app.addListener("window", handler);
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
cleanup.push(() => app.removeListener("window", handler));
|
const stdout = app.process().stdout!;
|
||||||
|
const onData = (chunk: any) => stdoutBuf += chunk.toString();
|
||||||
|
|
||||||
const { stdout } = app.process();
|
stdout.on("data", onData);
|
||||||
|
cleanup.push(() => stdout.off("data", onData));
|
||||||
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();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user