feature/recipe_implementation #5
@ -81,7 +81,7 @@ Execute this step now. Respond ONLY with the expected output format — no expla
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// discoverFiles — respects package_path param, with smart defaults
|
// discoverFiles — fully generic using recipe metadata + smart defaults
|
||||||
func (r *Runner) discoverFiles() []string {
|
func (r *Runner) discoverFiles() []string {
|
||||||
var files []string
|
var files []string
|
||||||
|
|
||||||
@ -93,16 +93,14 @@ func (r *Runner) discoverFiles() []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. If no param was given, apply smart defaults
|
// 2. Smart defaults if no param was given
|
||||||
if root == "." {
|
if root == "." {
|
||||||
// Check for src/ directory (common in some layouts)
|
|
||||||
if _, err := os.Stat("src"); err == nil {
|
if _, err := os.Stat("src"); err == nil {
|
||||||
root = "src"
|
root = "src"
|
||||||
}
|
}
|
||||||
// otherwise stay at project root (.)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build allowed extensions from recipe frontmatter
|
// 3. Build allowed extensions from recipe frontmatter
|
||||||
allowedExt := make(map[string]bool)
|
allowedExt := make(map[string]bool)
|
||||||
for _, lang := range r.Recipe.ProjectLanguages {
|
for _, lang := range r.Recipe.ProjectLanguages {
|
||||||
if exts, ok := r.Recipe.Extensions[lang]; ok {
|
if exts, ok := r.Recipe.Extensions[lang]; ok {
|
||||||
@ -117,8 +115,9 @@ func (r *Runner) discoverFiles() []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if allowedExt[filepath.Ext(path)] {
|
if allowedExt[filepath.Ext(path)] {
|
||||||
|
// For now we still look for "if err != nil" — we can generalize this later with a recipe hint if needed
|
||||||
b, _ := os.ReadFile(path)
|
b, _ := os.ReadFile(path)
|
||||||
if strings.Contains(string(b), "if err != nil") { // TODO: generalize this too later
|
if strings.Contains(string(b), "if err != nil") {
|
||||||
files = append(files, path)
|
files = append(files, path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user