MCPcopy Index your code
hub / github.com/github/awesome-copilot / parseToolVersion

Function parseToolVersion

extensions/java-modernization-studio/doctor.mjs:39–54  ·  view source on GitHub ↗
(key, text)

Source from the content-addressed store, hash-verified

37
38/** Extract a short version string from a tool's --version output. Pure. */
39export function parseToolVersion(key, text) {
40 if (!text) return null;
41 const t = String(text);
42 if (key === "java") {
43 const m = t.match(/version\s+"?([\d._]+)"?/i);
44 if (m) return m[1];
45 }
46 if (key === "node") {
47 const m = t.match(/v?(\d+\.\d+\.\d+)/);
48 if (m) return m[1];
49 }
50 const g = t.match(/(\d+\.\d+(?:\.\d+)?)/);
51 if (g) return g[1];
52 const first = t.split(/\r?\n/)[0].trim();
53 return first ? first.slice(0, 40) : null;
54}
55
56function defaultExec(cmd, args) {
57 return makeExec(augmentedEnv(process.env, platform()))(cmd, args);

Callers 2

cockpit.test.mjsFile · 0.90
probeOneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected