Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #93 from arifemre/patch-2
Browse files Browse the repository at this point in the history
Update build.go
  • Loading branch information
markbates committed Jan 6, 2017
2 parents c30db36 + 3a66b41 commit d6b1358
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions buffalo/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ package cmd
import (
"bytes"
"fmt"
"github.com/gobuffalo/velvet"
"github.com/spf13/cobra"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strings"
"time"

"github.com/gobuffalo/velvet"
"github.com/spf13/cobra"
)

var outputBinName string
Expand Down Expand Up @@ -146,8 +146,8 @@ func (b *builder) buildRiceZip() error {
}
rx := regexp.MustCompile("(rice.FindBox|rice.MustFindBox)")
if rx.Match(s) {
gopath := filepath.Join(os.Getenv("GOPATH"), "src")
pkg := filepath.Dir(strings.Replace(path, gopath+"/", "", -1))
gopath := strings.Replace(filepath.Join(os.Getenv("GOPATH"), "src"), "\\", "/", -1)
pkg := strings.Replace(filepath.Dir(strings.Replace(path, gopath+"/", "", -1)), "\\", "/", -1)
paths[pkg] = true
}
}
Expand Down Expand Up @@ -219,8 +219,8 @@ func (b *builder) buildMain() error {
}
ctx := velvet.NewContext()
ctx.Set("root", root)
ctx.Set("modelsPack", filepath.Join(packagePath(root), "models"))
ctx.Set("aPack", filepath.Join(packagePath(root), "a"))
ctx.Set("modelsPack", packagePath(root)+"/models")
ctx.Set("aPack", packagePath(root)+"/a")
ctx.Set("name", filepath.Base(root))
s, err := velvet.Render(buildMainTmpl, ctx)
if err != nil {
Expand Down Expand Up @@ -328,7 +328,13 @@ var buildCmd = &cobra.Command{
func init() {
RootCmd.AddCommand(buildCmd)
pwd, _ := os.Getwd()
buildCmd.Flags().StringVarP(&outputBinName, "output", "o", filepath.Join("bin", filepath.Base(pwd)), "set the name of the binary")
output := filepath.Join("bin", filepath.Base(pwd))

if runtime.GOOS == "windows" {
output += ".exe"
}

buildCmd.Flags().StringVarP(&outputBinName, "output", "o", output, "set the name of the binary")
buildCmd.Flags().BoolVarP(&zipBin, "zip", "z", false, "zips the assets to the binary, this requires zip installed")
}

Expand Down

0 comments on commit d6b1358

Please sign in to comment.