Integrated clean task

This commit is contained in:
Thomas Boerger 2015-08-27 10:12:29 +02:00
parent d1b36e868a
commit 7e21566af3

42
make.go
View file

@ -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) {