Skip to content

Commit

Permalink
Fix case where truffle contract build directory is absolute path.
Browse files Browse the repository at this point in the history
  • Loading branch information
nebojsa94 committed Feb 4, 2019
1 parent 4d059f0 commit af72a40
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions commands/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/tenderly/tenderly-cli/userError"
"io"
"io/ioutil"
"net/http"
Expand All @@ -16,6 +13,10 @@ import (
"strings"
"time"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/tenderly/tenderly-cli/userError"

"github.com/tenderly/tenderly-cli/ethereum"
"github.com/tenderly/tenderly-cli/ethereum/client"
"github.com/tenderly/tenderly-cli/jsonrpc2"
Expand Down
6 changes: 1 addition & 5 deletions commands/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func uploadContracts(rest *rest.Rest) error {
)
}

contracts, err := getTruffleContracts(filepath.Join(projectDir, truffleConfig.BuildDirectory))
contracts, err := getTruffleContracts(truffleConfig.AbsoluteBuildDirectoryPath())

logrus.Info("We have detected the following Smart Contracts:")
for _, contract := range contracts {
Expand Down Expand Up @@ -128,10 +128,6 @@ func getTruffleConfig(configName string, projectDir string) (*truffle.Config, er
return nil, fmt.Errorf("cannot read %s", configName)
}

if truffleConfig.BuildDirectory == "" {
truffleConfig.BuildDirectory = filepath.Join(".", "build", "contracts")
}

truffleConfig.ProjectDirectory = projectDir

return &truffleConfig, nil
Expand Down
11 changes: 10 additions & 1 deletion truffle/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@ type Config struct {
}

func (c *Config) AbsoluteBuildDirectoryPath() string {
return filepath.Join(c.ProjectDirectory, c.BuildDirectory)
if c.BuildDirectory == "" {
c.BuildDirectory = filepath.Join(".", "build", "contracts")
}

switch c.BuildDirectory[0] {
case '.':
return filepath.Join(c.ProjectDirectory, c.BuildDirectory)
default:
return c.BuildDirectory
}
}

0 comments on commit af72a40

Please sign in to comment.