From 574800c24146d6c2f695d1032d4193d0d53b2d15 Mon Sep 17 00:00:00 2001 From: "Arik Jones (aider)" Date: Sun, 22 Sep 2024 17:06:18 -0500 Subject: [PATCH] fix: Update runRollup function to accept config parameter --- cmd/files.go | 16 ++++++++-------- cmd/files_test.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/files.go b/cmd/files.go index d6e6a7a..90ea22b 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -24,7 +24,7 @@ var filesCmd = &cobra.Command{ in a given project, current path or a custom path, to a single timestamped markdown file whose name is -rollup-.md.`, RunE: func(cmd *cobra.Command, args []string) error { - return runRollup() + return runRollup(cfg) }, } @@ -103,21 +103,21 @@ func isIgnored(filePath string, patterns []string) bool { return false } -func runRollup() error { +func runRollup(config *config.Config) error { // Use config if available, otherwise use command-line flags var types, codeGenList, ignoreList []string - if cfg != nil && len(cfg.FileTypes) > 0 { - types = cfg.FileTypes + if config != nil && len(config.FileTypes) > 0 { + types = config.FileTypes } else { types = strings.Split(fileTypes, ",") } - if cfg != nil && len(cfg.CodeGenerated) > 0 { - codeGenList = cfg.CodeGenerated + if config != nil && len(config.CodeGenerated) > 0 { + codeGenList = config.CodeGenerated } else { codeGenList = strings.Split(codeGenPatterns, ",") } - if cfg != nil && cfg.Ignore != nil && len(cfg.Ignore) > 0 { - ignoreList = cfg.Ignore + if config != nil && config.Ignore != nil && len(config.Ignore) > 0 { + ignoreList = config.Ignore } else { ignoreList = strings.Split(ignorePatterns, ",") } diff --git a/cmd/files_test.go b/cmd/files_test.go index 1a3c334..ef2da82 100644 --- a/cmd/files_test.go +++ b/cmd/files_test.go @@ -123,7 +123,7 @@ func TestRunRollup(t *testing.T) { defer os.Chdir(originalWd) // Run the rollup - if err := runRollup(); err != nil { + if err := runRollup(cfg); err != nil { t.Fatalf("runRollup() failed: %v", err) }