Skip to content
TypeScript

fix(desktop): print version before initializing the app (#15440)

mariae01e58916fa5
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index d1c32d5ae7c..2b095807fb5 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -8,6 +8,8 @@ for (const stream of [process.stdout, process.stderr]) {
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient";
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
import * as NodeServices from "@effect/platform-node/NodeServices";
+// @effect-diagnostics-next-line nodeBuiltinImport:off - Version output must flush before Electron exits, without acquiring the runtime.
+import * as NodeFS from "node:fs";
import * as NodeOS from "node:os";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
@@ -69,6 +71,15 @@ import * as DesktopWslBackend from "./wsl/DesktopWslBackend.ts";
import * as DesktopWslEnvironment from "./wsl/DesktopWslEnvironment.ts";
import * as DesktopWslServerTree from "./wsl/DesktopWslServerTree.ts";
+if (process.argv.includes("--version")) {
+ try {
+ NodeFS.writeSync(process.stdout.fd, `${Electron.app.getVersion()}\n`);
+ } catch (error) {
+ if (!(error instanceof Error) || !("code" in error) || error.code !== "EPIPE") throw error;
+ }
+ Electron.app.exit(0);
+}
+
const desktopEnvironmentLayer = Layer.unwrap(
Effect.gen(function* () {
const metadata = yield* Effect.service(ElectronApp.ElectronApp).pipe(