Skip to content

Commit

Permalink
ci: Fix testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Aervyon committed Aug 12, 2024
1 parent bd2bcf6 commit 7dcdfa0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
11 changes: 8 additions & 3 deletions cmd/install/folderr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
6 changes: 5 additions & 1 deletion cmd/install/folderr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utilities/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 7dcdfa0

Please sign in to comment.