github.com/kngu9/glide@v0.0.0-20160505135211-e73500c73591/repo/vendored_cleanup.go (about) 1 package repo 2 3 import ( 4 "os" 5 "path/filepath" 6 7 "github.com/Masterminds/glide/cfg" 8 "github.com/Masterminds/glide/msg" 9 gpath "github.com/Masterminds/glide/path" 10 ) 11 12 // VendoredCleanup cleans up vendored codebases after an update. 13 // 14 // This should _only_ be run for installations that do not want VCS repos inside 15 // of the vendor/ directory. 16 func VendoredCleanup(conf *cfg.Config) error { 17 vend, err := gpath.Vendor() 18 if err != nil { 19 return err 20 } 21 22 for _, dep := range conf.Imports { 23 if dep.UpdateAsVendored == true { 24 msg.Info("Cleaning up vendored package %s\n", dep.Name) 25 26 // Remove the VCS directory 27 cwd := filepath.Join(vend, dep.Name) 28 repo, err := dep.GetRepo(cwd) 29 if err != nil { 30 msg.Err("Error cleaning up %s:%s", dep.Name, err) 31 continue 32 } 33 t := repo.Vcs() 34 err = os.RemoveAll(cwd + string(os.PathSeparator) + "." + string(t)) 35 if err != nil { 36 msg.Err("Error cleaning up VCS dir for %s:%s", dep.Name, err) 37 } 38 } 39 40 } 41 42 return nil 43 }