github.com/gobuffalo/buffalo-cli/v2@v2.0.0-alpha.15.0.20200919213536-a7350c8e6799/cli/internal/plugins/grifts/importer/importer.go (about)

     1  package importer
     2  
     3  import (
     4  	"context"
     5  	"path/filepath"
     6  
     7  	"github.com/gobuffalo/buffalo-cli/v2/cli/cmds/build"
     8  	"github.com/gobuffalo/here"
     9  	"github.com/gobuffalo/plugins"
    10  )
    11  
    12  var _ build.Importer = Importer{}
    13  var _ plugins.Plugin = Importer{}
    14  
    15  type Importer struct{}
    16  
    17  func (Importer) PluginName() string {
    18  	return "grifts/importer"
    19  }
    20  
    21  func (Importer) BuildImports(ctx context.Context, root string) ([]string, error) {
    22  	dir := filepath.Join(root, "grifts")
    23  	info, err := here.Dir(dir)
    24  	if err != nil {
    25  		return nil, nil
    26  	}
    27  	return []string{info.ImportPath}, nil
    28  }