Skip to content

Commit

Permalink
fix(core): recognise dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedsaheed committed Jun 22, 2024
1 parent 4f9a8cf commit 4b6ab49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion file_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func GetEncounteredLangs() []Language {

func hasExpectedLanguage(file string, expectedExt []string) bool {
for _, ext := range expectedExt {
if strings.HasSuffix(file, ext) {
if strings.HasSuffix(file, ext) || isDockerfile(file) {
return true
}
}
Expand Down
6 changes: 6 additions & 0 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func GetAllLanguagesInDir(root string) []Language {
ext := fileExtensionFromPath(path)
langName := lookupLangByExtension(ext)
lang := Languages[langName]
if isDockerfile(path) && ext == "." {
langName = "Dockerfile"
lang = Languages[langName]
}
if len(lang.Name) != 0 && !alreadyInserted[lang.Name] {
availableLangs = append(availableLangs, lang)
alreadyInserted[lang.Name] = true
Expand Down Expand Up @@ -102,6 +106,8 @@ func randomInt(min, max int) int {
return min + rand.Intn(max-min)
}

func isDockerfile(file string) bool { return strings.HasSuffix(file, "Dockerfile") }

func fileExtensionFromPath(path string) string {
return "." + strings.TrimPrefix(filepath.Ext(path), ".")
}
Expand Down

0 comments on commit 4b6ab49

Please sign in to comment.