MCPcopy Create free account
hub / github.com/HashLoad/boss / getNewPathsFromDir

Function getNewPathsFromDir

utils/librarypath/librarypath.go:102–141  ·  view source on GitHub ↗
(path string, paths []string, fullPath bool, rootPath string)

Source from the content-addressed store, hash-verified

100}
101
102func getNewPathsFromDir(path string, paths []string, fullPath bool, rootPath string) []string {
103 _, e := os.Stat(path)
104 if os.IsNotExist(e) {
105 return paths
106 }
107
108 _ = filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
109 matched, _ := regexp.MatchString(consts.RegexArtifacts, info.Name())
110 if matched {
111 dir, _ := filepath.Split(path)
112 if !fullPath {
113 dir, _ = filepath.Rel(rootPath, dir)
114 }
115 if !utils.Contains(paths, dir) {
116 paths = append(paths, dir)
117 }
118 // add ..\ prefixed path -> @MeroFuruya fix #146
119 prefixedPath := "..\\" + dir
120 if !utils.Contains(paths, prefixedPath) {
121 paths = append(paths, prefixedPath)
122 }
123 }
124 return nil
125 })
126
127 for _, path := range getDefaultPath(fullPath, rootPath) {
128 if !utils.Contains(paths, path) {
129 paths = append(paths, path)
130 }
131 // prevent variables from being prefixed
132 if !strings.HasPrefix(path, "$") {
133 // add ..\ prefixed path -> @MeroFuruya fix #146
134 prefixedPath := "..\\" + path
135 if !utils.Contains(paths, prefixedPath) {
136 paths = append(paths, prefixedPath)
137 }
138 }
139 }
140 return cleanEmpty(paths)
141}

Callers 1

GetNewPathsFunction · 0.85

Calls 3

ContainsFunction · 0.92
getDefaultPathFunction · 0.85
cleanEmptyFunction · 0.85

Tested by

no test coverage detected