fix: Update runRollup function to accept config parameter

This commit is contained in:
Arik Jones (aider)
2024-09-22 17:06:18 -05:00
parent d5a94f5468
commit 574800c241
2 changed files with 9 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ var filesCmd = &cobra.Command{
in a given project, current path or a custom path, to a single timestamped markdown file in a given project, current path or a custom path, to a single timestamped markdown file
whose name is <project-directory-name>-rollup-<timestamp>.md.`, whose name is <project-directory-name>-rollup-<timestamp>.md.`,
RunE: func(cmd *cobra.Command, args []string) error { 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 return false
} }
func runRollup() error { func runRollup(config *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 cfg != nil && len(cfg.FileTypes) > 0 { if config != nil && len(config.FileTypes) > 0 {
types = cfg.FileTypes types = config.FileTypes
} else { } else {
types = strings.Split(fileTypes, ",") types = strings.Split(fileTypes, ",")
} }
if cfg != nil && len(cfg.CodeGenerated) > 0 { if config != nil && len(config.CodeGenerated) > 0 {
codeGenList = cfg.CodeGenerated codeGenList = config.CodeGenerated
} else { } else {
codeGenList = strings.Split(codeGenPatterns, ",") codeGenList = strings.Split(codeGenPatterns, ",")
} }
if cfg != nil && cfg.Ignore != nil && len(cfg.Ignore) > 0 { if config != nil && config.Ignore != nil && len(config.Ignore) > 0 {
ignoreList = cfg.Ignore ignoreList = config.Ignore
} else { } else {
ignoreList = strings.Split(ignorePatterns, ",") ignoreList = strings.Split(ignorePatterns, ",")
} }

View File

@@ -123,7 +123,7 @@ func TestRunRollup(t *testing.T) {
defer os.Chdir(originalWd) defer os.Chdir(originalWd)
// Run the rollup // Run the rollup
if err := runRollup(); err != nil { if err := runRollup(cfg); err != nil {
t.Fatalf("runRollup() failed: %v", err) t.Fatalf("runRollup() failed: %v", err)
} }