@@ -20,7 +20,6 @@ import (
20
20
"strings"
21
21
22
22
"github.com/arduino/arduino-cli/arduino/globals"
23
- "github.com/arduino/arduino-cli/arduino/sketch"
24
23
"github.com/arduino/go-paths-helper"
25
24
properties "github.com/arduino/go-properties-orderedmap"
26
25
"github.com/pkg/errors"
@@ -176,19 +175,12 @@ func addExamples(lib *Library) error {
176
175
}
177
176
178
177
func addExamplesToPathList (examplesPath * paths.Path , list * paths.PathList ) error {
179
- files , err := examplesPath .ReadDir ( )
178
+ files , err := examplesPath .ReadDirRecursiveFiltered ( nil , filterExamplesDirs )
180
179
if err != nil {
181
180
return err
182
181
}
183
182
for _ , file := range files {
184
- _ , err := sketch .New (file )
185
- if err == nil {
186
- list .Add (file )
187
- } else if file .IsDir () {
188
- if err := addExamplesToPathList (file , list ); err != nil {
189
- return err
190
- }
191
- }
183
+ list .Add (file )
192
184
}
193
185
return nil
194
186
}
@@ -208,3 +200,8 @@ func containsHeaderFile(d *paths.Path) (bool, error) {
208
200
dirContent .FilterSuffix (headerExtensions ... )
209
201
return len (dirContent ) > 0 , nil
210
202
}
203
+
204
+ // filterExamplesDirs filters out any directory that does not contain a ".ino" or ".pde" file
205
+ func filterExamplesDirs (dir * paths.Path ) bool {
206
+ return dir .Join (dir .Base ()+ ".ino" ).Exist () || dir .Join (dir .Base ()+ ".pde" ).Exist ()
207
+ }
0 commit comments