diff --git a/main.go b/main.go index 7a11d77..c65e383 100644 --- a/main.go +++ b/main.go @@ -265,7 +265,7 @@ func filePathsFromArgs(args []string, includeDirectories bool) ([]string, error) var output []string var err error - if len(args) == 0 { + if len(args) == 0 || args[0] == "." { output, err = filepath.Glob("*") if err != nil { return []string{}, err diff --git a/main_test.go b/main_test.go index 396b9f2..1418a60 100644 --- a/main_test.go +++ b/main_test.go @@ -679,10 +679,35 @@ func Test_filePathsFromArgs(t *testing.T) { t.Error(err) } + // "." (current directory) as the only file path argument works the same as "*" + currentDir, err := os.Getwd() + if err != nil { + panic(err) + } + + err = os.Chdir(tempFolder()) + if err != nil { + panic(err) + } + + args = []string{"."} + + filePaths, err = filePathsFromArgs(args, true) + if err != nil { + t.Fatal(err) + } + + err = fileListsAreEqual(filePaths, tempFiles) + if err != nil { + t.Error(err) + } + + os.Chdir(currentDir) + // If no argument is provided, the function should default to "*" // in the current dir. - currentDir, err := os.Getwd() + currentDir, err = os.Getwd() if err != nil { panic(err) }