Skip to content

Windows run #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 13, 2020
Prev Previous commit
Next Next commit
parse version on windows
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Apr 13, 2020
commit 2c497e76e4a27c6a917b0a098c094e09f6184bf3
5 changes: 3 additions & 2 deletions src/services/dependencies/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { satisfies } from 'semver'
import { exec } from '../node'

const semverRegex = /(?<=^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-]+)*)?(?=$|\s)/gi
const semverRegex = /(?<=^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

export const version = async (name: string): Promise<string | null> => {
try {
const { stdout, stderr } = await exec(`${name} --version`)
if (!stderr) {
const match = stdout.match(semverRegex)
if (match) {
return match[0]
const parsedVersion = match[0].split('.').slice(0, 3).join('.')
return parsedVersion
}
}
return null
Expand Down