mage -> just
This commit is contained in:
parent
6fe2dcf3c8
commit
3687f27399
1
go.mod
1
go.mod
|
@ -7,7 +7,6 @@ require (
|
|||
github.com/go-chi/chi/v5 v5.0.11
|
||||
github.com/ilyakaznacheev/cleanenv v1.5.0
|
||||
github.com/madflojo/tasks v1.1.0
|
||||
github.com/magefile/mage v1.15.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
35
justfile
Normal file
35
justfile
Normal file
|
@ -0,0 +1,35 @@
|
|||
binary := "burningmoe"
|
||||
build_dir := "bin"
|
||||
cmd := "./cmd/web"
|
||||
output := "." / build_dir / binary
|
||||
|
||||
# do the thing
|
||||
default: run
|
||||
|
||||
# build binary
|
||||
build:
|
||||
go build -o {{output}} {{cmd}}
|
||||
|
||||
# run from source
|
||||
run:
|
||||
go run {{cmd}}
|
||||
|
||||
# build 'n run
|
||||
run-binary: build
|
||||
exec {{output}}
|
||||
|
||||
# run with args
|
||||
run-args args:
|
||||
go run {{cmd}} {{args}}
|
||||
|
||||
# install binary into $GOPATH
|
||||
install:
|
||||
go install {{cmd}}
|
||||
|
||||
# clean up after yourself
|
||||
clean:
|
||||
rm {{output}}
|
||||
|
||||
# run go tests
|
||||
test:
|
||||
go test ./...
|
38
magefile.go
38
magefile.go
|
@ -1,38 +0,0 @@
|
|||
//go:build mage
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/magefile/mage/sh"
|
||||
)
|
||||
|
||||
var (
|
||||
binaryName string = "burningmoe"
|
||||
buildDir string = "bin"
|
||||
cmd string = fmt.Sprintf(".%[1]ccmd%[1]cweb", os.PathSeparator)
|
||||
output string = fmt.Sprintf(".%[1]c%[2]s%[1]c%[3]s", os.PathSeparator, buildDir, binaryName)
|
||||
)
|
||||
|
||||
func Build() error {
|
||||
fmt.Println("Building...")
|
||||
return sh.Run("go", "build", "-o", output, cmd)
|
||||
}
|
||||
|
||||
func Run() error {
|
||||
fmt.Println("Running...")
|
||||
return sh.Run("go", "run", cmd)
|
||||
}
|
||||
|
||||
func RunBinary() error {
|
||||
Build()
|
||||
fmt.Println("Running binary...")
|
||||
return sh.Run(output)
|
||||
}
|
||||
|
||||
func Clean() error {
|
||||
fmt.Println("Cleaning...")
|
||||
return os.Remove(output)
|
||||
}
|
Loading…
Reference in a new issue