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