github.com/jfrog/jfrog-cli-core@v1.12.1/artifactory/utils/npm/cmd.go (about) 1 package npm 2 3 import ( 4 "io" 5 "os/exec" 6 "regexp" 7 ) 8 9 var npmCommands = regexp.MustCompile(`npm-install|npmi|npm-ci|npmci|npm-publish|npmp`) 10 11 func IsNpmCommand(cmd string) bool { 12 return npmCommands.MatchString(cmd) 13 } 14 15 func (config *NpmConfig) GetCmd() *exec.Cmd { 16 var cmd []string 17 cmd = append(cmd, config.Npm) 18 cmd = append(cmd, config.Command...) 19 cmd = append(cmd, config.CommandFlags...) 20 return exec.Command(cmd[0], cmd[1:]...) 21 } 22 23 func (config *NpmConfig) GetEnv() map[string]string { 24 return map[string]string{} 25 } 26 27 func (config *NpmConfig) GetStdWriter() io.WriteCloser { 28 return config.StrWriter 29 } 30 31 func (config *NpmConfig) GetErrWriter() io.WriteCloser { 32 return config.ErrWriter 33 } 34 35 type NpmConfig struct { 36 Npm string 37 Command []string 38 CommandFlags []string 39 StrWriter io.WriteCloser 40 ErrWriter io.WriteCloser 41 }