github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/add/add.go (about) 1 package add 2 3 import ( 4 "bytes" 5 "path/filepath" 6 7 "github.com/gobuffalo/buffalo/plugins/plugdeps" 8 "github.com/gobuffalo/genny/v2" 9 ) 10 11 // New add plugin to the config file 12 func New(opts *Options) (*genny.Generator, error) { 13 g := genny.New() 14 15 if err := opts.Validate(); err != nil { 16 return g, err 17 } 18 19 bb := &bytes.Buffer{} 20 plugs := plugdeps.New() 21 plugs.Add(opts.Plugins...) 22 if err := plugs.Encode(bb); err != nil { 23 return g, err 24 } 25 26 cpath := filepath.Join(opts.App.Root, "config", "buffalo-plugins.toml") 27 g.File(genny.NewFile(cpath, bb)) 28 29 return g, nil 30 }