pelican/magefile.go

45 lines
665 B
Go

//+build mage
package main
import (
"os"
"strings"
"github.com/magefile/mage/sh"
)
var Default = Build
// Clean clean the workspace
func Clean() error {
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 {
return sh.Run("go", "build", ".")
}