Skip to content

Commit 245ee4e

Browse files
Exclude libraries with a missing .h file from lib list
1 parent c73f735 commit 245ee4e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Diff for: commands/lib/list.go

+27
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ func listLibraries(lm *librariesmanager.LibrariesManager, updatable bool, all bo
135135
if updatable && available == nil {
136136
continue
137137
}
138+
if !containsDotH(lib) {
139+
continue
140+
}
138141
res = append(res, &installedLib{
139142
Library: lib,
140143
Available: available,
@@ -143,3 +146,27 @@ func listLibraries(lm *librariesmanager.LibrariesManager, updatable bool, all bo
143146
}
144147
return res
145148
}
149+
150+
// containsDotH returns true if the directory contains either a "library.properties"
151+
// or a ".h" file. Returns false otherwise
152+
func containsDotH(lib *libraries.Library) bool {
153+
if lib.InstallDir.Join("library.properties").Exist() {
154+
return true
155+
}
156+
src := lib.InstallDir.Join("src")
157+
rootContent, _ := lib.InstallDir.ReadDir()
158+
for _, file := range rootContent {
159+
if file.HasSuffix(".h") {
160+
return true
161+
}
162+
}
163+
if src.Exist() {
164+
srcContent, _ := src.ReadDir()
165+
for _, file := range srcContent {
166+
if file.HasSuffix(".h") {
167+
return true
168+
}
169+
}
170+
}
171+
return false
172+
}

0 commit comments

Comments
 (0)