Skip to content

Commit

Permalink
Added a fix for contracts on windows not getting detected on the file…
Browse files Browse the repository at this point in the history
…system.
  • Loading branch information
BogdanHabic committed Mar 17, 2020
1 parent b05bb06 commit ea7e5c7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions truffle/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"io/ioutil"
"path/filepath"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -115,8 +116,19 @@ func GetTruffleContracts(buildDir string, networkIDs ...string) ([]Contract, int

sources[contract.SourcePath] = true
for _, node := range contract.Ast.Nodes {
if node.NodeType == "ImportDirective" && !sources[node.AbsolutePath] {
sources[node.AbsolutePath] = false
if node.NodeType != "ImportDirective" {
continue
}

absPath := node.AbsolutePath
if runtime.GOOS == "windows" && strings.HasPrefix(absPath, "/") {
absPath = strings.ReplaceAll(absPath, "/", "\\")
absPath = strings.TrimPrefix(absPath, "\\")
absPath = strings.Replace(absPath, "\\", ":\\", 1)
}

if !sources[absPath] {
sources[absPath] = false
}
}

Expand Down

0 comments on commit ea7e5c7

Please sign in to comment.