/
managers.go
34 lines (27 loc) · 1.09 KB
/
managers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package depmanagers
import "github.com/bvobart/mllint/api"
var (
TypePoetry api.DependencyManagerType = typePoetry("Poetry")
TypePipenv api.DependencyManagerType = typePipenv("Pipenv")
TypeRequirementsTxt api.DependencyManagerType = typeRequirementsTxt("requirements.txt")
TypeSetupPy api.DependencyManagerType = typeSetupPy("setup.py")
)
// all is ordered by how recommended each manager is, i.e. the first one in this list is the type of dependency manager we want to recommend the most.
var all = []api.DependencyManagerType{
TypePoetry,
TypePipenv,
TypeRequirementsTxt,
TypeSetupPy,
}
//---------------------------------------------------------------------------------------
// Detect checks the files in the project directory to detect which dependency manager(s) is / are
// being used in this project.
func Detect(project api.Project) api.DependencyManagerList {
managers := api.DependencyManagerList{}
for _, managerType := range all {
if manager, err := managerType.Detect(project); err == nil {
managers = append(managers, manager)
}
}
return managers
}