Skip to content

Commit

Permalink
Find unformatted files in dir (Part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
incu6us committed Nov 25, 2023
1 parent dfb617c commit 306d78d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ func main() {
close(deprecatedMessagesCh)

if _, ok := reviser.IsDir(originPath); ok {
if *listFileName {
unformattedFiles, err := reviser.NewSourceDir(originProjectName, originPath, *isRecursive, excludes).Find(options...)
if err != nil {
log.Fatalf("Failed to find unformatted files %s: %+v\n", originPath, err)
}
for _, file := range unformattedFiles {
fmt.Printf("%s\n", file)
}
return
}
err := reviser.NewSourceDir(originProjectName, originPath, *isRecursive, excludes).Fix(options...)
if err != nil {
log.Fatalf("Failed to fix directory %s: %+v\n", originPath, err)
Expand Down
2 changes: 1 addition & 1 deletion reviser/dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func main() {
assert.NoError(tt, err)
var want []string
for _, w := range test.want {
want = append(want, rootPath+"/"+w)
want = append(want, filepath.Join(rootPath, w))
}
assert.Equal(tt, want, files)
return nil
Expand Down

0 comments on commit 306d78d

Please sign in to comment.