@@ -75,7 +75,11 @@ func findProjects(targetPath *paths.Path) ([]Type, error) {
75
75
return nil , fmt .Errorf ("specified path %s is not an Arduino project" , targetPath )
76
76
}
77
77
78
- foundProjects = append (foundProjects , findProjectsUnderPath (targetPath , configuration .SuperprojectTypeFilter (), configuration .Recursive ())... )
78
+ foundParentProjects := findProjectsUnderPath (targetPath , configuration .SuperprojectTypeFilter (), configuration .Recursive ())
79
+ for _ , foundParentProject := range foundParentProjects {
80
+ foundProjects = append (foundProjects , foundParentProject )
81
+ foundProjects = append (foundProjects , findSubprojects (foundParentProject , foundParentProject .ProjectType )... )
82
+ }
79
83
80
84
if foundProjects == nil {
81
85
return nil , fmt .Errorf ("no projects found under %s" , targetPath )
@@ -84,7 +88,7 @@ func findProjects(targetPath *paths.Path) ([]Type, error) {
84
88
return foundProjects , nil
85
89
}
86
90
87
- // findProjectsUnderPath finds projects of the given type and subprojects of those projects . It returns a slice containing the definitions of all found projects.
91
+ // findProjectsUnderPath finds projects of the given type under the given path . It returns a slice containing the definitions of all found projects.
88
92
func findProjectsUnderPath (targetPath * paths.Path , projectTypeFilter projecttype.Type , recursive bool ) []Type {
89
93
var foundProjects []Type
90
94
@@ -99,8 +103,6 @@ func findProjectsUnderPath(targetPath *paths.Path, projectTypeFilter projecttype
99
103
}
100
104
foundProjects = append (foundProjects , foundProject )
101
105
102
- foundProjects = append (foundProjects , findSubprojects (foundProject , foundProject .ProjectType )... )
103
-
104
106
// Don't search recursively past a project.
105
107
return foundProjects
106
108
}
@@ -120,7 +122,7 @@ func findProjectsUnderPath(targetPath *paths.Path, projectTypeFilter projecttype
120
122
// findSubprojects finds subprojects of the given project.
121
123
// For example, the subprojects of a library are its example sketches.
122
124
func findSubprojects (superproject Type , apexSuperprojectType projecttype.Type ) []Type {
123
- subprojectFolderNames := []string {}
125
+ subprojectsFolderNames := []string {}
124
126
var subProjectType projecttype.Type
125
127
var searchPathsRecursively bool
126
128
@@ -130,11 +132,11 @@ func findSubprojects(superproject Type, apexSuperprojectType projecttype.Type) [
130
132
// Sketches don't have subprojects
131
133
return nil
132
134
case projecttype .Library :
133
- subprojectFolderNames = append (subprojectFolderNames , library .ExamplesFolderSupportedNames ()... )
135
+ subprojectsFolderNames = append (subprojectsFolderNames , library .ExamplesFolderSupportedNames ()... )
134
136
subProjectType = projecttype .Sketch
135
137
searchPathsRecursively = true // Examples sketches can be under nested subfolders
136
138
case projecttype .Platform :
137
- subprojectFolderNames = append (subprojectFolderNames , platform .BundledLibrariesFolderNames ()... )
139
+ subprojectsFolderNames = append (subprojectsFolderNames , platform .BundledLibrariesFolderNames ()... )
138
140
subProjectType = projecttype .Library
139
141
searchPathsRecursively = false // Bundled libraries must be in the root of the libraries folder
140
142
case projecttype .PackageIndex :
@@ -146,9 +148,19 @@ func findSubprojects(superproject Type, apexSuperprojectType projecttype.Type) [
146
148
147
149
// Search the subproject paths for projects.
148
150
var immediateSubprojects []Type
149
- for _ , subprojectFolderName := range subprojectFolderNames {
150
- subprojectPath := superproject .Path .Join (subprojectFolderName )
151
- immediateSubprojects = append (immediateSubprojects , findProjectsUnderPath (subprojectPath , subProjectType , searchPathsRecursively )... )
151
+ for _ , subprojectsFolderName := range subprojectsFolderNames {
152
+ subprojectsPath := superproject .Path .Join (subprojectsFolderName )
153
+ if subprojectsPath .Exist () {
154
+ directoryListing , err := subprojectsPath .ReadDir ()
155
+ if err != nil {
156
+ panic (err )
157
+ }
158
+ directoryListing .FilterDirs ()
159
+
160
+ for _ , subprojectPath := range directoryListing {
161
+ immediateSubprojects = append (immediateSubprojects , findProjectsUnderPath (subprojectPath , subProjectType , searchPathsRecursively )... )
162
+ }
163
+ }
152
164
}
153
165
154
166
var allSubprojects []Type
0 commit comments