Spaces:
Paused
Paused
icebear0828 Claude Opus 4.6 commited on
Commit ·
504b471
1
Parent(s): 068f359
fix: use getRootDir() for package.json in self-update detection
Browse filesIn Electron, process.cwd() points to the system directory instead of
the app root, causing getProxyInfo() to return version "unknown". This
made update detection always fail since "1.0.x" < "unknown" lexically.
Add rootDir to PathConfig and getRootDir() helper so Electron can pass
app.getAppPath() for correct package.json resolution.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- src/paths.ts +6 -0
- src/self-update.ts +2 -2
src/paths.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
| 8 |
import { resolve } from "path";
|
| 9 |
|
| 10 |
interface PathConfig {
|
|
|
|
| 11 |
configDir: string;
|
| 12 |
dataDir: string;
|
| 13 |
binDir: string;
|
|
@@ -25,6 +26,11 @@ export function setPaths(config: PathConfig): void {
|
|
| 25 |
_paths = config;
|
| 26 |
}
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
/** Directory containing YAML config files. */
|
| 29 |
export function getConfigDir(): string {
|
| 30 |
return _paths?.configDir ?? resolve(process.cwd(), "config");
|
|
|
|
| 8 |
import { resolve } from "path";
|
| 9 |
|
| 10 |
interface PathConfig {
|
| 11 |
+
rootDir: string;
|
| 12 |
configDir: string;
|
| 13 |
dataDir: string;
|
| 14 |
binDir: string;
|
|
|
|
| 26 |
_paths = config;
|
| 27 |
}
|
| 28 |
|
| 29 |
+
/** App root directory (where package.json lives). */
|
| 30 |
+
export function getRootDir(): string {
|
| 31 |
+
return _paths?.rootDir ?? process.cwd();
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
/** Directory containing YAML config files. */
|
| 35 |
export function getConfigDir(): string {
|
| 36 |
return _paths?.configDir ?? resolve(process.cwd(), "config");
|
src/self-update.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { execFile, execFileSync } from "child_process";
|
|
| 9 |
import { existsSync, readFileSync } from "fs";
|
| 10 |
import { resolve } from "path";
|
| 11 |
import { promisify } from "util";
|
| 12 |
-
import { isEmbedded } from "./paths.js";
|
| 13 |
|
| 14 |
const execFileAsync = promisify(execFile);
|
| 15 |
|
|
@@ -58,7 +58,7 @@ let _checking = false;
|
|
| 58 |
export function getProxyInfo(): ProxyInfo {
|
| 59 |
let version = "unknown";
|
| 60 |
try {
|
| 61 |
-
const pkg = JSON.parse(readFileSync(resolve(
|
| 62 |
version = pkg.version ?? "unknown";
|
| 63 |
} catch { /* ignore */ }
|
| 64 |
|
|
|
|
| 9 |
import { existsSync, readFileSync } from "fs";
|
| 10 |
import { resolve } from "path";
|
| 11 |
import { promisify } from "util";
|
| 12 |
+
import { getRootDir, isEmbedded } from "./paths.js";
|
| 13 |
|
| 14 |
const execFileAsync = promisify(execFile);
|
| 15 |
|
|
|
|
| 58 |
export function getProxyInfo(): ProxyInfo {
|
| 59 |
let version = "unknown";
|
| 60 |
try {
|
| 61 |
+
const pkg = JSON.parse(readFileSync(resolve(getRootDir(), "package.json"), "utf-8")) as { version?: string };
|
| 62 |
version = pkg.version ?? "unknown";
|
| 63 |
} catch { /* ignore */ }
|
| 64 |
|