ProcessAll processes components starting at base
(base string)
| 14 | |
| 15 | // ProcessAll processes components starting at base |
| 16 | func ProcessAll(base string) error { |
| 17 | |
| 18 | err := filepath.Walk(base, func(path string, info os.FileInfo, err error) error { |
| 19 | if err != nil { |
| 20 | return err |
| 21 | } |
| 22 | if !info.IsDir() && files.IsHTML(info) { |
| 23 | f, err := os.Open(path) |
| 24 | if err != nil { |
| 25 | return err |
| 26 | } |
| 27 | //c, _ := component.Parse(f, componentName(path)) |
| 28 | |
| 29 | route := files.RouteName(path) |
| 30 | gfn := filepath.Join(base, strings.ToLower(route)+".go") |
| 31 | _, err = os.Stat(gfn) |
| 32 | var makeStruct bool |
| 33 | if os.IsNotExist(err) { |
| 34 | makeStruct = true |
| 35 | } |
| 36 | /*gofile, err := os.Create(goFileName(base, componentName(path))) |
| 37 | if err != nil { |
| 38 | return err |
| 39 | } |
| 40 | defer gofile.Close() |
| 41 | |
| 42 | c.Transform(gofile) |
| 43 | */ |
| 44 | appPkg := envy.CurrentPackage() |
| 45 | transpiler, err := component.NewTranspiler(f, makeStruct, appPkg, route, "routes") |
| 46 | if err != nil { |
| 47 | log.Println("ERROR", err) |
| 48 | return err |
| 49 | } |
| 50 | |
| 51 | gofile, err := os.Create(files.GeneratedGoFileName(base, route)) |
| 52 | if err != nil { |
| 53 | log.Println("ERROR", err) |
| 54 | return err |
| 55 | } |
| 56 | defer gofile.Close() |
| 57 | _, err = io.WriteString(gofile, transpiler.Code()) |
| 58 | if err != nil { |
| 59 | log.Println("ERROR", err) |
| 60 | return err |
| 61 | } |
| 62 | } |
| 63 | return nil |
| 64 | }) |
| 65 | |
| 66 | if err != nil { |
| 67 | log.Printf("error walking the path %q: %v\n", base, err) |
| 68 | } |
| 69 | return err |
| 70 | } |
no test coverage detected