github.com/gobuffalo/buffalo-cli/v2@v2.0.0-alpha.15.0.20200919213536-a7350c8e6799/cli/cmds/build/package.go (about)

     1  package build
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/gobuffalo/here"
     7  	"github.com/gobuffalo/plugins"
     8  )
     9  
    10  func (bc *Cmd) pack(ctx context.Context, info here.Info, plugs []plugins.Plugin) error {
    11  	var files []string
    12  	for _, p := range plugs {
    13  		pkg, ok := p.(PackFiler)
    14  		if !ok {
    15  			continue
    16  		}
    17  		res, err := pkg.PackageFiles(ctx, info.Dir)
    18  		if err != nil {
    19  			return plugins.Wrap(p, err)
    20  		}
    21  		files = append(files, res...)
    22  	}
    23  
    24  	for _, p := range plugs {
    25  		if pkg, ok := p.(Packager); ok {
    26  
    27  			if err := pkg.Package(ctx, info.Dir, files); err != nil {
    28  				return plugins.Wrap(p, err)
    29  			}
    30  		}
    31  	}
    32  	return nil
    33  }