Skip to content

Commit

Permalink
Move the execCommand to the Cli interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisWiegman committed Jun 19, 2024
1 parent 1900f98 commit cbcad66
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
6 changes: 6 additions & 0 deletions internal/site/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package site

import (
"fmt"
"os/exec"
"strings"

"github.com/ChrisWiegman/kana/internal/console"
Expand All @@ -11,6 +12,11 @@ import (
type Cli interface {
WordPress(command string, restart, root bool) (docker.ExecResult, error)
WPCli(command []string, interactive bool, consoleOutput *console.Console) (statusCode int64, output string, err error)
Command(name string, arg ...string) *exec.Cmd
}

func Command(name string, arg ...string) *exec.Cmd {
return exec.Command(name, arg...)
}

// RunWPCli Runs a wp-cli command returning it's output and any errors.
Expand Down
29 changes: 29 additions & 0 deletions internal/site/mocks/Cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions internal/site/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"net/url"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -35,8 +34,6 @@ type SiteInfo struct {

const DefaultType = "site"

var execCommand = exec.Command

func Load(site *Site, kanaSettings *settings.Settings) {
site.settings = kanaSettings
}
Expand Down Expand Up @@ -226,7 +223,7 @@ func (s *Site) OpenSite(openDatabaseFlag, openMailpitFlag, openSiteFlag, openAdm
}

if runtime.GOOS == "linux" {
openCmd := execCommand("xdg-open", openURL)
openCmd := s.Cli.Command("xdg-open", openURL)
return openCmd.Run()
}

Expand Down

0 comments on commit cbcad66

Please sign in to comment.