mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 13:32:24 +00:00
fixed cli to skip some type of directories and files
This commit is contained in:
parent
0d5dff1979
commit
139ddcbeec
@ -21,7 +21,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
errors := false
|
errors := false
|
||||||
o := make(map[string][]string, 0)
|
out := make(map[string][]string, 0)
|
||||||
err = filepath.Walk(root, func(path string, f os.FileInfo, err error) error {
|
err = filepath.Walk(root, func(path string, f os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors = true
|
errors = true
|
||||||
@ -29,7 +29,23 @@ func main() {
|
|||||||
return filepath.SkipDir
|
return filepath.SkipDir
|
||||||
}
|
}
|
||||||
|
|
||||||
if slinguist.IsVendor(f.Name()) || slinguist.IsDotFile(f.Name()) {
|
relativePath, err := filepath.Rel(root, path)
|
||||||
|
if err != nil {
|
||||||
|
errors = true
|
||||||
|
log.Println(err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if relativePath == "." {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if f.IsDir() {
|
||||||
|
relativePath = relativePath + "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
if slinguist.IsVendor(relativePath) || slinguist.IsDotFile(relativePath) ||
|
||||||
|
slinguist.IsDocumentation(relativePath) || slinguist.IsConfiguration(relativePath) {
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
return filepath.SkipDir
|
return filepath.SkipDir
|
||||||
}
|
}
|
||||||
@ -48,16 +64,12 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
l := slinguist.GetLanguage(filepath.Base(path), content)
|
language := slinguist.GetLanguage(filepath.Base(path), content)
|
||||||
|
if language == slinguist.OtherLanguage {
|
||||||
r, err := filepath.Rel(root, path)
|
|
||||||
if err != nil {
|
|
||||||
errors = true
|
|
||||||
log.Println(err)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
o[l] = append(o[l], r)
|
out[language] = append(out[language], relativePath)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -65,8 +77,8 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
js, _ := json.MarshalIndent(o, "", " ")
|
data, _ := json.MarshalIndent(out, "", " ")
|
||||||
fmt.Printf("%s\n", js)
|
fmt.Printf("%s\n", data)
|
||||||
|
|
||||||
if errors {
|
if errors {
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
|
Loading…
Reference in New Issue
Block a user