From 7dcdfa01b9d55a2f82f480af464daa6c80675e4c Mon Sep 17 00:00:00 2001 From: Aervyon Date: Mon, 12 Aug 2024 03:45:54 -0500 Subject: [PATCH] ci: Fix testing --- cmd/install/folderr.go | 11 ++++++++--- cmd/install/folderr_test.go | 6 +++++- go.mod | 2 +- utilities/system.go | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cmd/install/folderr.go b/cmd/install/folderr.go index 057a43d..29be814 100644 --- a/cmd/install/folderr.go +++ b/cmd/install/folderr.go @@ -86,19 +86,24 @@ var installFolderr = &cobra.Command{ cmd.Println("NPM appears to be installed") cmd.Println("Checking for TypeScript installation") tsc, err := utilities.FindSystemCommandVersion(cmd.OutOrStdout(), "tsc", true, "Version ") - if err != nil { + if err != nil && !strings.Contains(err.Error(), "Is tsc installed?") { return err } swc, err := utilities.FindSystemCommandVersion(cmd.OutOrStdout(), "swc", true, "@swc/cli: ") - if err != nil { + if err != nil && !strings.Contains(err.Error(), "Is swc installed?") { return err } if tsc == "" && swc == "" { cmd.Println("Neither TypeScript nor SWC not installed. Aborting.") cmd.Println("Install TypeScript or SWC before running this command!") return nil + } else if tsc == "" { + cmd.Println("SWC appears to be installed") + } else if swc == "" { + cmd.Println("TypeScript appears to be installed") + } else { + cmd.Println("Both SWC and TypeScript are installed, try SWC first") } - cmd.Println("TypeScript or SWC appears to be installed") // Turn Node version into a int! versions := []int{} diff --git a/cmd/install/folderr_test.go b/cmd/install/folderr_test.go index e3cb2e4..21dbe25 100644 --- a/cmd/install/folderr_test.go +++ b/cmd/install/folderr_test.go @@ -37,11 +37,15 @@ func TestInstall(t *testing.T) { if err != nil { t.Errorf(`Command "`+utilities.Constants.RootCmdName+` install folderr %v" failed because of error, %v`, args[0], err) } + buildCmd := "npm run build:tsc" + if strings.Contains(actual.String(), "SWC appears to be installed") || strings.Contains(actual.String(), "Both SWC and TypeScript are installed") { + buildCmd = "npm run build" + } suffix := []string{ "Clone successful", "Checkout successful", "Install seems to have gone correctly.", - `To build Folderr go to "` + sharedConfig.Directory + `" and type "npm run build:production"`, + `To build Folderr go to "` + sharedConfig.Directory + `" and type "` + buildCmd + `"`, } for _, i := range suffix { if !strings.Contains(actual.String(), i) { diff --git a/go.mod b/go.mod index cbfe495..57811cd 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/Folderr/foldcli go 1.20 require ( + github.com/Masterminds/semver v1.5.0 github.com/fossoreslp/go-uuid-v4 v1.0.0 github.com/go-git/go-git/v5 v5.10.0 github.com/manifoldco/promptui v0.9.0 @@ -14,7 +15,6 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect - github.com/Masterminds/semver v1.5.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect github.com/acomagu/bufpipe v1.0.4 // indirect diff --git a/utilities/system.go b/utilities/system.go index 8e19d06..4b15dca 100644 --- a/utilities/system.go +++ b/utilities/system.go @@ -8,7 +8,7 @@ import ( ) func FindSystemCommandVersion(w io.Writer, command string, hasPrefix bool, prefix string) (string, error) { - execCmd, err := FindSystemCommand(w, command, []string{"-v"}) + execCmd, err := FindSystemCommand(w, command, []string{"--version"}) if err != nil { return "", err }