diff --git a/make.go b/make.go index 3eea7696b..f85bd28fa 100644 --- a/make.go +++ b/make.go @@ -34,6 +34,7 @@ var steps = map[string]step{ "build": build, "test": test, "image": image, + "clean": clean, } func main() { @@ -170,6 +171,47 @@ func image() error { return nil } +func clean() error { + err := filepath.Walk(".", func(path string, f os.FileInfo, err error) error { + suffixes := []string{ + ".out", + "_bindata.go", + } + + for _, suffix := range suffixes { + if strings.HasSuffix(path, suffix) { + if err := os.Remove(path); err != nil { + return err + } + } + } + + return nil + }) + + if err != nil { + return err + } + + files := []string{ + "bin/drone", + "bin/drone-agent", + "bin/drone-build", + } + + for _, file := range files { + if _, err := os.Stat(file); err != nil { + continue + } + + if err := os.Remove(file); err != nil { + return err + } + } + + return nil +} + // trace is a helper fucntion that writes a command // to stdout similar to bash +x func trace(args []string) {