| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | | import { execFileSync, spawn, type ChildProcess } from "node:child_process"; |
| 1 | import { spawn, type ChildProcess } from "node:child_process"; |
| 2 | 2 | import { randomBytes } from "node:crypto"; |
| 3 | 3 | import fs from "node:fs"; |
| 4 | 4 | import net from "node:net"; |
| ... | ... | @@ -110,28 +110,13 @@ function resolveEmbeddedCommitHash(): string | null { |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | | function resolveGitCommitHash(): string | null { |
| 114 | | try { |
| 115 | | const stdout = execFileSync("git", ["rev-parse", `--short=${COMMIT_HASH_DISPLAY_LENGTH}`, "HEAD"], { |
| 116 | | cwd: ROOT_DIR, |
| 117 | | encoding: "utf8", |
| 118 | | stdio: ["ignore", "pipe", "ignore"], |
| 119 | | }); |
| 120 | | return normalizeCommitHash(stdout); |
| 121 | | } catch { |
| 122 | | return null; |
| 123 | | } |
| 124 | | } |
| 125 | | |
| 126 | 113 | function resolveAboutCommitHash(): string | null { |
| 127 | 114 | if (aboutCommitHashCache !== undefined) { |
| 128 | 115 | return aboutCommitHashCache; |
| 129 | 116 | } |
| 130 | 117 | |
| 131 | 118 | aboutCommitHashCache = |
| 132 | | normalizeCommitHash(process.env.T3CODE_COMMIT_HASH) ?? |
| 133 | | resolveEmbeddedCommitHash() ?? |
| 134 | | resolveGitCommitHash(); |
| 119 | normalizeCommitHash(process.env.T3CODE_COMMIT_HASH) ?? resolveEmbeddedCommitHash(); |
| 135 | 120 | |
| 136 | 121 | return aboutCommitHashCache; |
| 137 | 122 | } |
| ... | ... | @@ -483,11 +468,7 @@ function registerIpcHandlers(): void { |
| 483 | 468 | ipcMain.removeHandler(CONTEXT_MENU_CHANNEL); |
| 484 | 469 | ipcMain.handle( |
| 485 | 470 | CONTEXT_MENU_CHANNEL, |
| 486 | | async ( |
| 487 | | _event, |
| 488 | | items: ContextMenuItem[], |
| 489 | | position?: { x: number; y: number }, |
| 490 | | ) => { |
| 471 | async (_event, items: ContextMenuItem[], position?: { x: number; y: number }) => { |
| 491 | 472 | const normalizedItems = items |
| 492 | 473 | .filter((item) => typeof item.id === "string" && typeof item.label === "string") |
| 493 | 474 | .map((item) => ({ |
| ... | ... | @@ -538,7 +519,7 @@ function registerIpcHandlers(): void { |
| 538 | 519 | const menu = Menu.buildFromTemplate(template); |
| 539 | 520 | menu.popup({ |
| 540 | 521 | window, |
| 541 | | ...(popupPosition ?? {}), |
| 522 | ...popupPosition, |
| 542 | 523 | callback: () => resolve(null), |
| 543 | 524 | }); |
| 544 | 525 | }); |