-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_content.go
62 lines (50 loc) · 1.21 KB
/
file_content.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import "strings"
var EncounteredLangsArr = []Language{}
func SetEncounteredLangs(lang Language) {
EncounteredLangsArr = append(EncounteredLangsArr, lang)
}
func GetEncounteredLangs() []Language {
return EncounteredLangsArr
}
func hasExpectedLanguage(file string, expectedExt []string) bool {
for _, ext := range expectedExt {
if strings.HasSuffix(file, ext) || isDockerfile(file) {
return true
}
}
return false
}
var ignoredDirs = []string{".git", ".idea", "node_modules", "vendor"}
var ignoreFiles = []string{".DS_Store", ".gitignore", ".gitkeep", "package-lock.json", "yarn.lock"}
func isIgnoredDir(dir string) bool {
for _, d := range ignoredDirs {
if strings.Contains(dir, d) {
return true
}
}
return false
}
func isDotedDir(dir string) bool {
firstSlash := strings.Index(dir, "/")
if firstSlash == -1 {
return false
}
secondSlash := strings.Index(dir[firstSlash+1:], "/")
if secondSlash == -1 {
return false
}
secondSlash += firstSlash + 1
if len(dir) > secondSlash+1 && dir[secondSlash+1] == '.' {
return true
}
return false
}
func isIgnoredFile(file string) bool {
for _, f := range ignoreFiles {
if strings.HasSuffix(file, f) {
return true
}
}
return false
}