github.com/jfrog/jfrog-cli-core@v1.12.1/artifactory/utils/yarn/configget.go (about)

     1  package yarn
     2  
     3  import (
     4  	gofrogcmd "github.com/jfrog/gofrog/io"
     5  	"github.com/jfrog/jfrog-client-go/utils/errorutils"
     6  	"strings"
     7  )
     8  
     9  func ConfigGet(key, executablePath string, jsonOutput bool) (string, error) {
    10  	var flags []string = nil
    11  	if jsonOutput {
    12  		flags = append(flags, "--json")
    13  	}
    14  	configGetCmdConfig := createConfigGetCmdConfig(executablePath, key, flags)
    15  	output, err := gofrogcmd.RunCmdOutput(configGetCmdConfig)
    16  	if err != nil {
    17  		return "", errorutils.CheckError(err)
    18  	}
    19  	confValue := strings.TrimSpace(output)
    20  
    21  	return confValue, nil
    22  }
    23  
    24  func createConfigGetCmdConfig(executablePath, confName string, flags []string) *YarnConfig {
    25  	return &YarnConfig{
    26  		Executable:   executablePath,
    27  		Command:      []string{"config", "get", confName},
    28  		CommandFlags: flags,
    29  		StrWriter:    nil,
    30  		ErrWriter:    nil,
    31  	}
    32  }