@@ -53,7 +53,7 @@ func FindProjects() ([]Type, error) {
53
53
54
54
// findProjects handles the recursion for FindProjects().
55
55
func findProjects (targetPath * paths.Path ) ([]Type , error ) {
56
- var foundProjects []Type
56
+ var foundParentProjects []Type
57
57
58
58
// If targetPath is a file, targetPath itself is the project, so it's only necessary to determine/verify the type.
59
59
if targetPath .IsNotDir () {
@@ -82,39 +82,33 @@ func findProjects(targetPath *paths.Path) ([]Type, error) {
82
82
ProjectType : projectType ,
83
83
SuperprojectType : projectType ,
84
84
}
85
- foundProjects = append (foundProjects , foundProject )
86
-
87
- foundProjects = append (foundProjects , findSubprojects (foundProject , projectType )... )
88
-
89
- return foundProjects , nil
85
+ foundParentProjects = append (foundParentProjects , foundProject )
90
86
}
91
-
92
- return nil , fmt .Errorf ("Specified path %s is not an Arduino project" , targetPath )
93
- }
94
-
95
- var foundParentProjects []Type
96
- if configuration .SuperprojectTypeFilter () == projecttype .All || configuration .Recursive () {
97
- // Project discovery and/or type detection is required.
98
- foundParentProjects = findProjectsUnderPath (targetPath , configuration .SuperprojectTypeFilter (), configuration .Recursive ())
99
87
} else {
100
- // Project was explicitly defined by user.
101
- foundParentProjects = append (foundParentProjects ,
102
- Type {
103
- Path : targetPath ,
104
- ProjectType : configuration .SuperprojectTypeFilter (),
105
- SuperprojectType : configuration .SuperprojectTypeFilter (),
106
- },
107
- )
88
+ if configuration .SuperprojectTypeFilter () == projecttype .All || configuration .Recursive () {
89
+ // Project discovery and/or type detection is required.
90
+ foundParentProjects = findProjectsUnderPath (targetPath , configuration .SuperprojectTypeFilter (), configuration .Recursive ())
91
+ } else {
92
+ // Project was explicitly defined by user.
93
+ foundParentProjects = append (foundParentProjects ,
94
+ Type {
95
+ Path : targetPath ,
96
+ ProjectType : configuration .SuperprojectTypeFilter (),
97
+ SuperprojectType : configuration .SuperprojectTypeFilter (),
98
+ },
99
+ )
100
+ }
108
101
}
109
102
110
103
// Discover subprojects of all found projects.
104
+ var foundProjects []Type
111
105
for _ , foundParentProject := range foundParentProjects {
112
106
foundProjects = append (foundProjects , foundParentProject )
113
107
foundProjects = append (foundProjects , findSubprojects (foundParentProject , foundParentProject .ProjectType )... )
114
108
}
115
109
116
110
if foundProjects == nil {
117
- return nil , fmt .Errorf ("No projects found under %s" , targetPath )
111
+ return nil , fmt .Errorf ("No projects found with project path %s" , targetPath )
118
112
}
119
113
120
114
return foundProjects , nil
0 commit comments