forked from Azure/azure-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmagefile.go
More file actions
49 lines (42 loc) · 694 Bytes
/
magefile.go
File metadata and controls
49 lines (42 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//go:build mage
// +build mage
package main
import (
"context"
"fmt"
"os"
"os/exec"
"github.com/magefile/mage/mg"
)
type AZD mg.Namespace
func (a AZD) Build(ctx context.Context) error {
cmdStr, cmd := runIn(
".",
"go",
"build",
"-o",
"./bin/azd",
"./cli/azd",
)
fmt.Println(cmdStr)
return cmd()
}
func (a AZD) Test(ctx context.Context) error {
cmdStr, cmd := runIn(
".",
"go",
"test",
"./...",
)
fmt.Println(cmdStr)
return cmd()
}
func runIn(cwd string, cmd string, args ...string) (string, func() error) {
c := exec.Command(cmd, args...)
c.Dir = cwd
c.Stdout = os.Stdout
c.Stderr = os.Stderr
return c.String(), func() error {
return c.Run()
}
}