ScanLuaCode scans the script folder for Lua files
(folder string)
| 59 | |
| 60 | // ScanLuaCode scans the script folder for Lua files |
| 61 | func ScanLuaCode(folder string) (*bytes.Buffer, error) { |
| 62 | buf := bytes.NewBuffer(nil) |
| 63 | |
| 64 | if folder == "" { |
| 65 | return buf, nil |
| 66 | } |
| 67 | |
| 68 | dir, err := os.ReadDir(folder) |
| 69 | if err != nil { |
| 70 | return nil, err |
| 71 | } |
| 72 | |
| 73 | for _, file := range dir { |
| 74 | if file.IsDir() { |
| 75 | continue |
| 76 | } |
| 77 | name := file.Name() |
| 78 | if !strings.HasSuffix(name, ".lua") { |
| 79 | continue |
| 80 | } |
| 81 | path := filepath.Join(folder, name) |
| 82 | f, err := os.Open(path) |
| 83 | if err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | _, err = io.Copy(buf, f) |
| 87 | f.Close() |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return buf, nil |
| 94 | } |
| 95 | |
| 96 | // ExtractFunctions extracts function names from Lua code |
| 97 | func ExtractFunctions(r io.Reader) []string { |
no test coverage detected