pelican/magefile.go

52 lines
769 B
Go
Raw Normal View History

2021-08-18 01:40:12 +01:00
//+build mage
package main
import (
"os"
"strings"
"github.com/magefile/mage/sh"
)
var Default = Build
2021-09-14 20:58:54 +01:00
var binary = "pelican"
2021-08-18 01:40:12 +01:00
// Clean clean the workspace
func Clean() error {
2021-09-14 20:58:54 +01:00
if err := os.Remove(binary); err != nil {
return err
}
2021-08-18 01:40:12 +01:00
if err := sh.Run("go", "clean", "./..."); err != nil {
return err
}
testDBDir := "./test/databases"
files, err := os.ReadDir(testDBDir)
if err != nil {
return err
}
for _, f := range files {
filename := f.Name()
if strings.HasSuffix(filename, ".db") {
os.Remove(testDBDir + "/" + filename)
}
}
return nil
}
// Test run the go tests
func Test() error {
return sh.Run("go", "test", ".")
}
// Build build the executable
func Build() error {
2021-09-14 20:58:54 +01:00
return sh.Run("go", "build", "-o", binary, "main.go")
2021-08-18 01:40:12 +01:00
}