Merge pull request #67 from mcarmonaa/fix/cli-optimization

check for extension and filename first, without load a file content
This commit is contained in:
Santiago M. Mola 2017-07-10 17:49:20 +02:00 committed by GitHub
commit 0582d61550

View File

@ -61,16 +61,21 @@ func main() {
return nil
}
content, err := ioutil.ReadFile(path)
if err != nil {
errors = true
log.Println(err)
return nil
}
language, ok := enry.GetLanguageByExtension(path)
if !ok {
if language, ok = enry.GetLanguageByFilename(path); !ok {
content, err := ioutil.ReadFile(path)
if err != nil {
errors = true
log.Println(err)
return nil
}
language := enry.GetLanguage(filepath.Base(path), content)
if language == enry.OtherLanguage {
return nil
language = enry.GetLanguage(filepath.Base(path), content)
if language == enry.OtherLanguage {
return nil
}
}
}
out[language] = append(out[language], relativePath)