forked from gobuffalo/packr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.go
40 lines (34 loc) · 818 Bytes
/
build.go
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
package cmd
import (
"context"
"os"
"os/exec"
"github.com/gobuffalo/packr"
"github.com/gobuffalo/packr/builder"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
// buildCmd represents the build command
var buildCmd = &cobra.Command{
Use: "build",
Short: "Wraps the go build command with packr",
DisableFlagParsing: true,
RunE: func(cmd *cobra.Command, args []string) error {
defer builder.Clean(input)
b := builder.New(context.Background(), input)
err := b.Run()
if err != nil {
return errors.WithStack(err)
}
cargs := []string{"build"}
cargs = append(cargs, args...)
cp := exec.Command(packr.GoBin(), cargs...)
cp.Stderr = os.Stderr
cp.Stdin = os.Stdin
cp.Stdout = os.Stdout
return cp.Run()
},
}
func init() {
rootCmd.AddCommand(buildCmd)
}