From 81cd5e85cbd61c1c0ded45cf7f8090eb89022296 Mon Sep 17 00:00:00 2001 From: JohnRowleySEL Date: Tue, 11 Apr 2017 12:17:40 -0700 Subject: [PATCH] Fixed retool sync on windows (#24) I changed a exec.Command call that called rm to os.RemoveAll. exec.Command breaks on windows because rm being called. Lastly I added a test to help prevent regression. --- retool_test.go | 15 +++++++++++++++ sync.go | 7 ++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/retool_test.go b/retool_test.go index 41491a5..b5b4af2 100644 --- a/retool_test.go +++ b/retool_test.go @@ -60,6 +60,21 @@ func TestRetool(t *testing.T) { } }) + t.Run("sync", func(t *testing.T) { + dir, cleanup := setupTempDir(t) + defer cleanup() + + runRetoolCmd(t, dir, retool, "add", "github.com/twitchtv/retool", "origin/master") + + // Delete existing tools directory to try and trigger out of date + _ = os.RemoveAll(filepath.Join(dir, "_tools")) + + // Should be able to sync + runRetoolCmd(t, dir, retool, "sync") + + assertBinInstalled(t, dir, "retool") + }) + t.Run("build", func(t *testing.T) { t.Parallel() dir, cleanup := setupTempDir(t) diff --git a/sync.go b/sync.go index 0f00d9c..1259518 100644 --- a/sync.go +++ b/sync.go @@ -1,15 +1,12 @@ package main -import "os/exec" +import "os" func (s spec) sync() { m := getManifest() if m.outOfDate(s.Tools) { - log("syncing") - // Delete existing tools directory - cmd := exec.Command("rm", "-r", "-f", toolDirPath) - _, err := cmd.Output() + err := os.RemoveAll(toolDirPath) if err != nil { fatalExec("failed to remove _tools ", err) }