generated from nhcarrigan/template
fix: extract semver before comparing CLI versions
The installed version string includes a suffix like '(Claude Code)' which caused Number() to parse the third segment as NaN, making the comparison always return 0 (current) instead of the correct result. Now extracts the semver portion with a regex before comparing.
This commit is contained in:
@@ -22,7 +22,9 @@
|
||||
if (installedVersion === "Loading..." || installedVersion === "Unknown") {
|
||||
return "neutral";
|
||||
}
|
||||
const cmp = compareVersions(installedVersion, SUPPORTED_CLI_VERSION);
|
||||
const semverMatch = /(\d+\.\d+\.\d+)/.exec(installedVersion);
|
||||
if (!semverMatch) return "neutral";
|
||||
const cmp = compareVersions(semverMatch[1], SUPPORTED_CLI_VERSION);
|
||||
if (cmp > 0) return "ahead";
|
||||
if (cmp < 0) return "behind";
|
||||
return "current";
|
||||
|
||||
Reference in New Issue
Block a user