Skip to content

Commit

Permalink
better make file
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Sep 26, 2018
1 parent 6037196 commit b6302e7
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
6 changes: 6 additions & 0 deletions genny/goreleaser/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package goreleaser

import (
"os/user"
"path/filepath"

"github.com/pkg/errors"
)
Expand Down Expand Up @@ -29,5 +30,10 @@ func (opts *Options) Validate() error {
}
opts.BrewOwner = user.Username
}
if len(opts.MainFile) > 0 {
if filepath.Ext(opts.MainFile) != ".go" {
return errors.Errorf("%s is not a .go file", opts.MainFile)
}
}
return nil
}
1 change: 1 addition & 0 deletions genny/initgen/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func New(opts *Options) (*genny.Group, error) {
g, err := makefile.New(&makefile.Options{
Force: opts.Force,
VersionFile: opts.VersionFile,
MainFile: opts.MainFile,
})
if err != nil {
return gg, errors.WithStack(err)
Expand Down
11 changes: 11 additions & 0 deletions genny/initgen/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package initgen

import (
"path/filepath"

"github.com/pkg/errors"
)

type Options struct {
VersionFile string
Version string
Expand All @@ -15,5 +21,10 @@ func (opts *Options) Validate() error {
if len(opts.VersionFile) == 0 {
opts.Version = "version.go"
}
if len(opts.MainFile) > 0 {
if filepath.Ext(opts.MainFile) != ".go" {
return errors.Errorf("%s is not a .go file", opts.MainFile)
}
}
return nil
}
2 changes: 1 addition & 1 deletion genny/makefile/a_makefile-packr.go

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

17 changes: 17 additions & 0 deletions genny/makefile/options.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package makefile

import (
"path/filepath"

"github.com/pkg/errors"
)

type Options struct {
Force bool
MainFile string
BuildPath string
VersionFile string
}

Expand All @@ -10,5 +18,14 @@ func (opts *Options) Validate() error {
if len(opts.VersionFile) == 0 {
opts.VersionFile = "version.go"
}
if len(opts.BuildPath) == 0 {
opts.BuildPath = "."
}
if len(opts.MainFile) > 0 {
if filepath.Ext(opts.MainFile) != ".go" {
return errors.Errorf("%s is not a .go file", opts.MainFile)
}
opts.BuildPath = filepath.Dir(opts.MainFile)
}
return nil
}
10 changes: 8 additions & 2 deletions genny/makefile/templates/Makefile.plush
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ GO_BIN ?= go

install:
packr
$(GO_BIN) install -v .
$(GO_BIN) install -v <%= opts.BuildPath %>

deps:
$(GO_BIN) get github.com/gobuffalo/release
$(GO_BIN) get github.com/gobuffalo/packr/packr
$(GO_BIN) get -tags ${TAGS} -t ./...
ifeq ($(GO111MODULE),on)
$(GO_BIN) mod tidy
endif

build:
packr
Expand All @@ -19,19 +21,23 @@ test:
packr
$(GO_BIN) test -tags ${TAGS} ./...

ci-test: deps
ci-test:
$(GO_BIN) test -tags ${TAGS} -race ./...

lint:
gometalinter --vendor ./... --deadline=1m --skip=internal

update:
$(GO_BIN) get -u -tags ${TAGS}
ifeq ($(GO111MODULE),on)
$(GO_BIN) mod tidy
endif
packr
make test
make install
ifeq ($(GO111MODULE),on)
$(GO_BIN) mod tidy
endif

release-test:
$(GO_BIN) test -tags ${TAGS} -race ./...
Expand Down

0 comments on commit b6302e7

Please sign in to comment.