Skip to content

Commit 6527900

Browse files
committed
chore: update version check output
1 parent 0eacb90 commit 6527900

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

src/lib/env-check.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@ import { checkCommand } from './process.js'
33
import { getPythonCommand } from './platform.js'
44
import type { EnvCheckResult, EnvCheckSummary } from '../types/env.js'
55

6+
function normalizeVersion(
7+
version: string | undefined,
8+
name: string,
9+
command: string,
10+
): string | undefined {
11+
if (!version) return version
12+
13+
let normalized = version.trim()
14+
const prefixes = [name, command]
15+
16+
for (const prefix of prefixes) {
17+
const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
18+
normalized = normalized.replace(
19+
new RegExp(`^${escaped}(?:\\s+version)?\\s+`, 'i'),
20+
'',
21+
)
22+
}
23+
24+
return normalized
25+
}
26+
627
async function checkTool(
728
name: string,
829
command: string,
@@ -14,7 +35,7 @@ async function checkTool(
1435
name,
1536
command,
1637
found: result.found,
17-
version: result.version,
38+
version: normalizeVersion(result.version, name, command),
1839
required,
1940
}
2041
}

0 commit comments

Comments
 (0)