8000 refactor(cmd): replace cmd.getModule() by ilgooz · Pull Request #620 · ignite/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor(cmd): replace cmd.getModule() #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
2 changes: 1 addition & 1 deletion starport/interface/cli/starport/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewBuild() *cobra.Command {
}

func buildHandler(cmd *cobra.Command, args []string) error {
path, err := gomodulepath.Parse(getModule(appPath))
path, err := gomodulepath.ParseAt(appPath)
if err != nil {
return err
}
Expand Down
14 changes: 0 additions & 14 deletions starport/interface/cli/starport/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ package starportcmd

import (
"fmt"
"io/ioutil"
"log"
"path/filepath"
"strings"

"github.com/fatih/color"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -38,16 +34,6 @@ func New() *cobra.Command {
return c
}

func getModule(path string) string {
goModFile, err := ioutil.ReadFile(filepath.Join(path, "go.mod"))
if err != nil {
log.Fatal(err)
}
moduleString := strings.Split(string(goModFile), "\n")[0]
modulePath := strings.ReplaceAll(moduleString, "module ", "")
return modulePath
}

func logLevel(cmd *cobra.Command) chain.LogLevel {
verbose, _ := cmd.Flags().GetBool("verbose")
if verbose {
Expand Down
4 changes: 2 additions & 2 deletions starport/interface/cli/starport/cmd/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewRelayerAdd() *cobra.Command {
}

func relayerInfoHandler(cmd *cobra.Command, args []string) error {
path, err := gomodulepath.Parse(getModule(appPath))
path, err := gomodulepath.ParseAt(appPath)
if err != nil {
return err
}
Expand All @@ -64,7 +64,7 @@ func relayerInfoHandler(cmd *cobra.Command, args []string) error {
}

func relayerAddHandler(cmd *cobra.Command, args []string) error {
path, err := gomodulepath.Parse(getModule(appPath))
path, err := gomodulepath.ParseAt(appPath)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion starport/interface/cli/starport/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewServe() *cobra.Command {
}

func serveHandler(cmd *cobra.Command, args []string) error {
path, err := gomodulepath.Parse(getModule(appPath))
path, err := gomodulepath.ParseAt(appPath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions starport/pkg/gomodulepath/gomodulepath.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func Parse(rawpath string) (Path, error) {
return p, nil
}

// ParseFile parses Go module path of an app resides at path.
func ParseFile(path string) (Path, error) {
// ParseAt parses Go module path of an app resides at path.
func ParseAt(path string) (Path, error) {
parsed, err := gomodule.ParseAt(path)
if err != nil {
return Path{}, err
Expand Down
2 changes: 1 addition & 1 deletion starport/services/networkbuilder/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newBlockchain(ctx context.Context, builder *Builder, chainID, appPath, url,
func (b *Blockchain) init(ctx context.Context, chainID string, mustNotInitializedBefore bool) error {
b.builder.ev.Send(events.New(events.StatusOngoing, "Initializing the blockchain"))

path, err := gomodulepath.ParseFile(b.appPath)
path, err := gomodulepath.ParseAt(b.appPath)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion starport/services/networkbuilder/networkbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (b *Builder) StartChain(ctx context.Context, chainID string, flags []string
}

appPath := filepath.Join(sourcePath, chainID)
path, err := gomodulepath.ParseFile(appPath)
path, err := gomodulepath.ParseAt(appPath)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion starport/services/networkbuilder/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (b *Builder) VerifyProposals(ctx context.Context, chainID string, proposals
defer os.RemoveAll(tmpHome)

appPath := filepath.Join(sourcePath, chainID)
path, err := gomodulepath.ParseFile(appPath)
path, err := gomodulepath.ParseAt(appPath)
if err != nil {
return false, err
}
Expand Down
4 changes: 2 additions & 2 deletions starport/services/scaffolder/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *Scaffolder) CreateModule(moduleName string) error {
if ok {
return fmt.Errorf("the module %v already exists", moduleName)
}
path, err := gomodulepath.ParseFile(s.path)
path, err := gomodulepath.ParseAt(s.path)
if err != nil {
return err
}
Expand Down Expand Up @@ -96,7 +96,7 @@ func (s *Scaffolder) ImportModule(name string) error {
return err
}

path, err := gomodulepath.ParseFile(s.path)
path, err := gomodulepath.ParseAt(s.path)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion starport/services/scaffolder/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (s *Scaffolder) AddType(moduleName string, stype string, fields ...string)
if err != nil {
return err
}
path, err := gomodulepath.ParseFile(s.path)
path, err := gomodulepath.ParseAt(s.path)
if err != nil {
return err
}
Expand Down
0