fix: inline compareSemver in gsd extension to fix broken relative import (#1058)
The /gsd update command imported compareSemver from ../../../update-check.js, a relative path that resolves correctly in the source tree (src/resources/ extensions/gsd/ → src/update-check.js) but breaks when extensions are synced to ~/.gsd/agent/extensions/gsd/ (where ../../../ points to ~/.gsd/ which has no update-check.js). This caused the error: Extension "command:gsd" error: Cannot find module '../../../update-check.js' Fix: inline a local compareSemverLocal() function in commands.ts, eliminating the cross-tree import. The function is small (10 lines) and already well-tested via update-check.test.ts.
This commit is contained in:
parent
41ebc6b643
commit
3d4f77b2ee
1 changed files with 13 additions and 2 deletions
|
|
@ -2283,9 +2283,20 @@ Examples:
|
|||
|
||||
// ─── Self-update handler ────────────────────────────────────────────────────
|
||||
|
||||
function compareSemverLocal(a: string, b: string): number {
|
||||
const pa = a.split('.').map(Number)
|
||||
const pb = b.split('.').map(Number)
|
||||
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
||||
const va = pa[i] || 0
|
||||
const vb = pb[i] || 0
|
||||
if (va > vb) return 1
|
||||
if (va < vb) return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
async function handleUpdate(ctx: ExtensionCommandContext): Promise<void> {
|
||||
const { execSync } = await import("node:child_process");
|
||||
const { compareSemver } = await import("../../../update-check.js");
|
||||
|
||||
const NPM_PACKAGE = "gsd-pi";
|
||||
const current = process.env.GSD_VERSION || "0.0.0";
|
||||
|
|
@ -2303,7 +2314,7 @@ async function handleUpdate(ctx: ExtensionCommandContext): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
if (compareSemver(latest, current) <= 0) {
|
||||
if (compareSemverLocal(latest, current) <= 0) {
|
||||
ctx.ui.notify(`Already up to date (v${current}).`, "info");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue