mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-15 15:03:17 +00:00
fix: Update runRollup function to accept config parameter
This commit is contained in:
16
cmd/files.go
16
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
|
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, ",")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user