MCPcopy Index your code
hub / github.com/coderoad/coderoad-vscode / getVersion

Function getVersion

src/services/dependencies/index.ts:7–21  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

5 /(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(\.windows.[0-9]+)?(?=$|\s)/gi
6
7export const getVersion = async (name: string): Promise<{ version: string | null; error: Error | null }> => {
8 try {
9 const { stdout, stderr } = await exec({ command: `${name} --version` })
10 if (!stderr) {
11 const match = stdout.match(semverRegex)
12 if (match) {
13 const parsedVersion = match[0].split('.').slice(0, 3).join('.')
14 return { version: parsedVersion, error: null }
15 }
16 }
17 return { version: null, error: null }
18 } catch (error: any) {
19 return { version: null, error }
20 }
21}
22
23export const compareVersions = async (currentVersion: string, expectedVersion: string): Promise<never | boolean> => {
24 // see node-semver docs: https://github.com/npm/node-semver

Callers 3

onTutorialConfigNewFunction · 0.90
onValidateSetupFunction · 0.90
initFunction · 0.90

Calls 1

execFunction · 0.90

Tested by

no test coverage detected