diff --git a/pkg/cmd/init/init.go b/pkg/cmd/init/init.go index 81973b4bb..fcc96c043 100644 --- a/pkg/cmd/init/init.go +++ b/pkg/cmd/init/init.go @@ -182,7 +182,7 @@ func (cmd *InitCmd) Run(info *InitInfo) error { } if shouldDeps { - answer, err := getPackageManager() + answer, err := utils.GetPackageManager() if err != nil { return err } @@ -215,7 +215,7 @@ func (cmd *InitCmd) Run(info *InitInfo) error { } if shouldDeps { - answer, err := getPackageManager() + answer, err := utils.GetPackageManager() if err != nil { return err } diff --git a/pkg/cmd/init/utils.go b/pkg/cmd/init/utils.go index 632d5f3af..5ac8bbd24 100644 --- a/pkg/cmd/init/utils.go +++ b/pkg/cmd/init/utils.go @@ -120,17 +120,3 @@ func depsInstall(cmd *InitCmd, packageManager string) error { return nil } - -func getPackageManager() (string, error) { - opts := []string{"npm", "yarn"} - answer := "" - prompt := &survey.Select{ - Message: "Choose a package manager:", - Options: opts, - } - err := survey.AskOne(prompt, &answer) - if err != nil { - return "", err - } - return answer, nil -} diff --git a/pkg/cmd/link/link.go b/pkg/cmd/link/link.go index 52c8b52ea..a44665f4e 100644 --- a/pkg/cmd/link/link.go +++ b/pkg/cmd/link/link.go @@ -191,7 +191,7 @@ func (cmd *LinkCmd) run(info *LinkInfo, options *contracts.AzionApplicationOptio } if shouldDeps { - answer, err := getPackageManager() + answer, err := utils.GetPackageManager() if err != nil { return err } @@ -224,7 +224,7 @@ func (cmd *LinkCmd) run(info *LinkInfo, options *contracts.AzionApplicationOptio } if shouldYarn { - answer, err := getPackageManager() + answer, err := utils.GetPackageManager() if err != nil { return err } diff --git a/pkg/cmd/link/utils.go b/pkg/cmd/link/utils.go index 58d5131cc..460bc3c71 100644 --- a/pkg/cmd/link/utils.go +++ b/pkg/cmd/link/utils.go @@ -130,17 +130,3 @@ func depsInstall(cmd *LinkCmd, packageManager string) error { return nil } - -func getPackageManager() (string, error) { - opts := []string{"npm", "yarn"} - answer := "" - prompt := &survey.Select{ - Message: "Choose a package manager:", - Options: opts, - } - err := survey.AskOne(prompt, &answer) - if err != nil { - return "", err - } - return answer, nil -} diff --git a/utils/helpers.go b/utils/helpers.go index f171f487c..1275e5ff9 100644 --- a/utils/helpers.go +++ b/utils/helpers.go @@ -12,6 +12,7 @@ import ( "strings" "time" + "github.com/AlecAivazis/survey/v2" msg "github.com/aziontech/azion-cli/messages/edge_applications" "github.com/aziontech/azion-cli/pkg/cmdutil" "github.com/aziontech/azion-cli/pkg/contracts" @@ -363,3 +364,17 @@ func TruncateString(str string) string { func IsEmpty(str string) bool { return len(str) < 1 } + +func GetPackageManager() (string, error) { + opts := []string{"npm", "yarn"} + answer := "" + prompt := &survey.Select{ + Message: "Choose a package manager:", + Options: opts, + } + err := survey.AskOne(prompt, &answer) + if err != nil { + return "", err + } + return answer, nil +}