From e98272c218cd5adad97475b1894adcb0c7aae8c8 Mon Sep 17 00:00:00 2001 From: Maksim Smirnov Date: Sat, 23 Aug 2025 10:18:07 +0200 Subject: [PATCH] fix error on missing files --- editorconfig/source_file_finder.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/editorconfig/source_file_finder.go b/editorconfig/source_file_finder.go index 090d192..6e749a5 100644 --- a/editorconfig/source_file_finder.go +++ b/editorconfig/source_file_finder.go @@ -69,6 +69,21 @@ func FindSourceFiles(searchPaths []string) ([]string, error) { return nil, cli.NewExitError(errMessage, 2) } + // Check if this is a specific file path (exists and is a file) + if fileInfo, err := os.Stat(searchPath); err == nil && !fileInfo.IsDir() { + // Don't run on files inside dot directories. + if !containsDotDirectoryRegex.MatchString(searchPath) { + // For explicitly specified files, always include them regardless of extension + files = append(files, searchPath) + } + continue + } + + // If the file doesn't exist, skip it silently (don't error out) + if _, err := os.Stat(searchPath); err != nil { + continue + } + _ = filepath.Walk(searchPath, func(path string, fileInfo os.FileInfo, err error) error { // Don't add paths that don't exist. if err != nil {