Skip to content

Commit 9c4905e

Browse files
authored
Fix npm version parsing command (#245)
* Fix npm get version * Update installorci.go
1 parent 690eb1c commit 9c4905e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

artifactory/commands/npm/installorci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func (nca *NpmCommandArgs) validateNpmVersion() error {
317317
}
318318
if npmVersion.Compare(minSupportedNpmVersion) > 0 {
319319
return errorutils.CheckError(errors.New(fmt.Sprintf(
320-
"JFrog CLI npm %s command requires npm client version "+minSupportedNpmVersion+" or higher", nca.command)))
320+
"JFrog CLI npm %s command requires npm client version " + minSupportedNpmVersion + " or higher. The Current version is: %s", nca.command, npmVersion.GetVersion())))
321321
}
322322
nca.npmVersion = npmVersion
323323
return nil

utils/npm/version.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ func Version(executablePath string) (*version.Version, error) {
2121

2222
func getVersion(executablePath string) (string, error) {
2323
command := exec.Command(executablePath, "-version")
24-
buffer := bytes.NewBuffer([]byte{})
25-
command.Stderr = buffer
26-
command.Stdout = buffer
24+
stderr := bytes.NewBuffer([]byte{})
25+
stdout := bytes.NewBuffer([]byte{})
26+
command.Stderr = stderr
27+
command.Stdout = stdout
2728
err := command.Run()
28-
return buffer.String(), coreutils.ConvertExitCodeError(errorutils.CheckError(err))
29+
if err != nil {
30+
err = coreutils.ConvertExitCodeError(err)
31+
return "", errorutils.CheckError(errors.New(stderr.String() + "-" + err.Error()))
32+
}
33+
return stdout.String(), nil
2934
}
3035

3136
func GetNpmVersionAndExecPath() (*version.Version, string, error) {

0 commit comments

Comments
 (0)