blob: 688ebf5de95962177feed5c19678116d240fe8b6 [file] [log] [blame]
Serge Bazanski31dd6162018-10-25 14:20:50 +02001package builder
2
3import (
4 "fmt"
5 "os"
6 "path/filepath"
7 "strings"
8
9 "github.com/pkg/errors"
10)
11
12// Clean up an *-packr.go files
13func Clean(root string) {
14 root, _ = filepath.EvalSymlinks(root)
15 filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
16 base := filepath.Base(path)
17 if base == ".git" || base == "vendor" || base == "node_modules" {
18 return filepath.SkipDir
19 }
20 if info == nil || info.IsDir() {
21 return nil
22 }
23 if strings.Contains(base, "-packr.go") {
24 err := os.Remove(path)
25 if err != nil {
26 fmt.Println(err)
27 return errors.WithStack(err)
28 }
29 }
30 return nil
31 })
32}