Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using sh.Run instead of exec.Command in the magefile default template #435

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions mage/magefile_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ package main
import (
"fmt"
"os"
"os/exec"

"github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps
"github.com/magefile/mage/sh"
)

// Default target to run when none is specified
Expand All @@ -21,8 +21,7 @@ import (
func Build() error {
mg.Deps(InstallDeps)
fmt.Println("Building...")
cmd := exec.Command("go", "build", "-o", "MyApp", ".")
return cmd.Run()
return sh.Run("go", "build", "-o", "MyApp", ".")
}

// A custom install step if you need your bin someplace other than go/bin
Expand All @@ -35,8 +34,7 @@ func Install() error {
// Manage your deps, or running package managers.
func InstallDeps() error {
fmt.Println("Installing Deps...")
cmd := exec.Command("go", "get", "github.com/stretchr/piglatin")
return cmd.Run()
return sh.Run("go", "get", "github.com/stretchr/piglatin")
}

// Clean up after yourself
Expand Down