From ea7e5c7993258f4ad326e1c4b1d5c9089d05f1eb Mon Sep 17 00:00:00 2001 From: Bogdan Habic Date: Tue, 17 Mar 2020 12:44:15 +0100 Subject: [PATCH] Added a fix for contracts on windows not getting detected on the filesystem. --- truffle/contract.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/truffle/contract.go b/truffle/contract.go index 87029da..d082709 100644 --- a/truffle/contract.go +++ b/truffle/contract.go @@ -4,6 +4,7 @@ import ( "encoding/json" "io/ioutil" "path/filepath" + "runtime" "strings" "time" @@ -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 } }