Added logic for file progression under different OS environments.
@@ -8,7 +8,6 @@ import (
"log"
"os"
"os/exec"
- "strings"
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/config"
@@ -21,8 +20,9 @@ const (
packageMain = "%s.go"
packageReadme = "README.md"
- exchangePackageLocation = "../../exchanges/"
- exchangeLocation = "../../exchange.go"
+ exchangePackageLocation = "..%s..%sexchanges%s"
+ exchangeLocation = "..%s..%sexchange.go"
+ exchangeConfigPath = "..%s..%stestdata%sconfigtest.json"
)
var (
@@ -32,6 +32,7 @@ var (
exchangeWrapper string
exchangeMain string
exchangeReadme string
+ exchangeJSON string
)
type exchange struct {
@@ -82,9 +83,8 @@ func main() {
}
newExchangeName = common.StringToLower(newExchangeName)
- split := strings.Split(newExchangeName, "")
- v := split[0]
- capName := common.StringToUpper(v) + strings.Join(split[1:], "")
+ v := newExchangeName[:1]
+ capName := common.StringToUpper(v) + newExchangeName[1:]
exch := exchange{
Name: newExchangeName,
@@ -95,8 +95,11 @@ func main() {
FIX: fixSupport,
}
+ osPathSlash := common.GetOSPathSlash()
+ exchangeJSON := fmt.Sprintf(exchangeConfigPath, osPathSlash, osPathSlash, osPathSlash)
+
configTestFile := config.GetConfig()
- err = configTestFile.LoadConfig("../../testdata/configtest.json")
+ err = configTestFile.LoadConfig(exchangeJSON)
if err != nil {
log.Fatal("GoCryptoTrader: Exchange templating configuration retrieval error ", err)
}
@@ -123,12 +126,18 @@ func main() {
configTestFile.Exchanges = append(configTestFile.Exchanges, newExchConfig)
// TODO sorting function so exchanges are in alphabetical order - low priority
- err = configTestFile.SaveConfig("../../testdata/configtest.json")
+ err = configTestFile.SaveConfig(exchangeJSON)
if err != nil {
log.Fatal("GoCryptoTrader: Exchange templating configuration error - cannot save")
}
- exchangeDirectory = exchangePackageLocation + newExchangeName + "/"
+ exchangeDirectory = fmt.Sprintf(
+ exchangePackageLocation+newExchangeName+"%s",
+ osPathSlash,
+ osPathSlash,
+ osPathSlash,
+ osPathSlash)
+
exchangeTest = fmt.Sprintf(exchangeDirectory+packageTests, newExchangeName)
exchangeTypes = fmt.Sprintf(exchangeDirectory+packageTypes, newExchangeName)
exchangeWrapper = fmt.Sprintf(exchangeDirectory+packageWrapper, newExchangeName)
@@ -200,11 +209,6 @@ func main() {
log.Fatal("GoCryptoTrader: Exchange templating tool go fmt error ", err)
}
- err = exec.Command("go", "fmt", exchangeDirectory).Run()
- if err != nil {
- log.Fatal("GoCryptoTrader: Exchange templating tool go fmt error ", err)
- }
-
err = exec.Command("go", "test", exchangeDirectory).Run()
if err != nil {
log.Fatal("GoCryptoTrader: Exchange templating tool testing failed ", err)
