Lucas Stadler лет назад: 11
Родитель
Сommit
f4953030cd
2 измененных файлов с 50 добавлено и 0 удалено
  1. 40 0
      go/detect.go
  2. 10 0
      go/fileutil/fileutil.go

+ 40 - 0
go/detect.go

26
26
27
var Detectors = []Detector{
27
var Detectors = []Detector{
28
	{Detection{"clojure", "leiningen"}, clojureLeiningen},
28
	{Detection{"clojure", "leiningen"}, clojureLeiningen},
29
	{Detection{"docker", "fig"}, dockerFig},
30
	{Detection{"docker", "default"}, dockerDefault},
31
	{Detection{"executable", "default"}, executableDefault},
29
	{Detection{"go", "default"}, goDefault},
32
	{Detection{"go", "default"}, goDefault},
30
	{Detection{"java", "maven"}, javaMaven},
33
	{Detection{"java", "maven"}, javaMaven},
34
	{Detection{"javascript", "npm"}, javascriptNpm},
35
	{Detection{"javascript", "meteor"}, javascriptMeteor},
36
	{Detection{"javascript", "default"}, javascriptDefault},
31
	{Detection{"make", "default"}, makeDefault},
37
	{Detection{"make", "default"}, makeDefault},
38
	{Detection{"procfile", "default"}, procfileDefault},
39
	{Detection{"python", "django"}, pythonDjango},
32
	{Detection{"python", "default"}, pythonDefault},
40
	{Detection{"python", "default"}, pythonDefault},
33
	{Detection{"ruby", "rails"}, rubyRails},
41
	{Detection{"ruby", "rails"}, rubyRails},
34
	{Detection{"ruby", "rake"}, rubyRake},
42
	{Detection{"ruby", "rake"}, rubyRake},
66
	return hasFile(file, "project.clj")
74
	return hasFile(file, "project.clj")
67
}
75
}
68
76
77
func dockerFig(file string) bool {
78
	return hasFile(file, "fig.yml")
79
}
80
81
func dockerDefault(file string) bool {
82
	return hasFile(file, "Dockerfile")
83
}
84
85
func executableDefault(file string) bool {
86
	return fileutil.IsExecutable(file)
87
}
88
69
func goDefault(file string) bool {
89
func goDefault(file string) bool {
70
	return matchingFileOrDir(file, "*.go")
90
	return matchingFileOrDir(file, "*.go")
71
}
91
}
74
	return hasFile(file, "pom.xml")
94
	return hasFile(file, "pom.xml")
75
}
95
}
76
96
97
func javascriptNpm(file string) bool {
98
	return hasFile(file, "package.json")
99
}
100
101
func javascriptMeteor(file string) bool {
102
	return hasFile(file, ".meteor/.id")
103
}
104
105
func javascriptDefault(file string) bool {
106
	return matchingFileOrDir(file, "*.js")
107
}
108
77
func makeDefault(file string) bool {
109
func makeDefault(file string) bool {
78
	return hasFile(file, "Makefile")
110
	return hasFile(file, "Makefile")
79
}
111
}
80
112
113
func procfileDefault(file string) bool {
114
	return hasFile(file, "Procfile")
115
}
116
117
func pythonDjango(file string) bool {
118
	return hasFile(file, "manage.py")
119
}
120
81
func pythonDefault(file string) bool {
121
func pythonDefault(file string) bool {
82
	return matchingFileOrDir(file, "*.py")
122
	return matchingFileOrDir(file, "*.py")
83
}
123
}

+ 10 - 0
go/fileutil/fileutil.go

34
	}
34
	}
35
	return path.Join(dir, path.Join(elem...))
35
	return path.Join(dir, path.Join(elem...))
36
}
36
}
37
38
func IsExecutable(file string) bool {
39
	info, err := os.Stat(file)
40
	if err != nil {
41
		return false
42
	}
43
44
	isExecutable := info.Mode() & 0111
45
	return isExecutable != 0 && !info.IsDir()
46
}