fix: resolve undefined config variable in cmd/files.go

This commit is contained in:
Arik Jones (aider)
2024-09-22 17:07:32 -05:00
parent 574800c241
commit 71f63ddaa8

View File

@@ -8,8 +8,11 @@ import (
"time" "time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/tnypxl/rollup/internal/config"
) )
var cfg *config.Config
var ( var (
path string path string
fileTypes string fileTypes string
@@ -103,21 +106,21 @@ func isIgnored(filePath string, patterns []string) bool {
return false return false
} }
func runRollup(config *config.Config) error { func runRollup(cfg *config.Config) error {
// Use config if available, otherwise use command-line flags // Use config if available, otherwise use command-line flags
var types, codeGenList, ignoreList []string var types, codeGenList, ignoreList []string
if config != nil && len(config.FileTypes) > 0 { if cfg != nil && len(cfg.FileTypes) > 0 {
types = config.FileTypes types = cfg.FileTypes
} else { } else {
types = strings.Split(fileTypes, ",") types = strings.Split(fileTypes, ",")
} }
if config != nil && len(config.CodeGenerated) > 0 { if cfg != nil && len(cfg.CodeGenerated) > 0 {
codeGenList = config.CodeGenerated codeGenList = cfg.CodeGenerated
} else { } else {
codeGenList = strings.Split(codeGenPatterns, ",") codeGenList = strings.Split(codeGenPatterns, ",")
} }
if config != nil && config.Ignore != nil && len(config.Ignore) > 0 { if cfg != nil && cfg.Ignore != nil && len(cfg.Ignore) > 0 {
ignoreList = config.Ignore ignoreList = cfg.Ignore
} else { } else {
ignoreList = strings.Split(ignorePatterns, ",") ignoreList = strings.Split(ignorePatterns, ",")
} }