Skip to content

Commit

Permalink
Merge 4989bda into a582188
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW authored Feb 13, 2023
2 parents a582188 + 4989bda commit 1b82ba0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func Bin(fsys fs.FS, bd string, force bool) (map[string]string, error) {
if d.IsDir() {
return nil
}
for _, i := range ignoreBinnameKeywords {
if strings.Contains(filepath.ToSlash(strings.ToLower(path)), filepath.ToSlash(strings.ToLower(i))) {
return nil
}
}

b, err := fs.ReadFile(fsys, path)
if err != nil {
return err
Expand Down Expand Up @@ -58,7 +64,7 @@ func Bin(fsys fs.FS, bd string, force bool) (map[string]string, error) {
}

var priorityPaths = []string{"/usr/local/bin", "/usr/bin"}
var ignoreKeywords = []string{
var ignorePathKeywords = []string{
"homebrew",
"X11",
"/usr/local/opt",
Expand All @@ -74,6 +80,12 @@ var ignoreKeywords = []string{
"/Library/",
"hostedtoolcache",
}
var ignoreBinnameKeywords = []string{
"CHANGELOG",
"README",
"CREDIT",
"LICENSE",
}

func binDir() (string, error) {
if os.Getenv("PATH") == "" {
Expand Down Expand Up @@ -103,7 +115,7 @@ func sortPaths(paths []string) ([]string, error) {
filtered := []string{}
L:
for _, p := range paths {
for _, i := range ignoreKeywords {
for _, i := range ignorePathKeywords {
if strings.Contains(filepath.ToSlash(strings.ToLower(p)), filepath.ToSlash(strings.ToLower(i))) {
continue L
}
Expand Down

0 comments on commit 1b82ba0

Please sign in to comment.