forked from jfrog/jfrog-cli-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversionVerify.go
More file actions
39 lines (34 loc) · 1.07 KB
/
Copy pathversionVerify.go
File metadata and controls
39 lines (34 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package yarn
import (
gofrogcmd "github.com/jfrog/gofrog/io"
"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"strings"
)
const unsupportedYarnVersion = "4.0.0"
func IsInstalledYarnVersionSupported(executablePath string) error {
versionGetCmdConfig := getVersionCmdConfig(executablePath)
output, err := gofrogcmd.RunCmdOutput(versionGetCmdConfig)
if err != nil {
return errorutils.CheckError(err)
}
yarnVersion := strings.TrimSpace(output)
return IsVersionSupported(yarnVersion)
}
func IsVersionSupported(versionStr string) error {
yarnVersion := version.NewVersion(versionStr)
if yarnVersion.Compare(unsupportedYarnVersion) <= 0 {
return errorutils.CheckErrorf("Yarn version 4 is not supported. The current version is: " + versionStr +
". Please downgrade to a compatible version to continue")
}
return nil
}
func getVersionCmdConfig(executablePath string) *YarnConfig {
return &YarnConfig{
Executable: executablePath,
Command: []string{"--version"},
CommandFlags: nil,
StrWriter: nil,
ErrWriter: nil,
}
}