github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state-installer/installer_lin_mac.go (about) 1 //go:build !windows 2 // +build !windows 3 4 package main 5 6 import ( 7 "os" 8 "path/filepath" 9 "strings" 10 11 "github.com/ActiveState/cli/internal/errs" 12 "github.com/ActiveState/cli/internal/fileutils" 13 ) 14 15 func (i *Installer) sanitizeInstallPath() error { 16 if !fileutils.DirExists(i.path) { 17 return nil 18 } 19 20 files, err := os.ReadDir(i.path) 21 if err != nil { 22 return errs.Wrap(err, "Could not installation directory: %s", i.path) 23 } 24 25 for _, file := range files { 26 fname := strings.ToLower(file.Name()) 27 if isStateExecutable(fname) { 28 err = os.Remove(filepath.Join(i.path, fname)) 29 if err != nil { 30 return errs.Wrap(err, "Could not remove") 31 } 32 } 33 } 34 35 return nil 36 }