From 7e21566af3f11966e319266f600e3397b24be0e6 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 27 Aug 2015 10:12:29 +0200 Subject: [PATCH] Integrated clean task --- make.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) 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) {