Skip to content

Commit 480e43b

Browse files
committed
fix windows command
1 parent a7bc3ca commit 480e43b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

toolchain/exec_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package toolchain
22

33
import (
44
"errors"
5+
"path/filepath"
56
"testing"
67

78
"github.com/cloudposse/atmos/pkg/schema"
@@ -84,8 +85,9 @@ func TestRunExecCommand_Success(t *testing.T) {
8485
t.Fatalf("expected no error, got %v", err)
8586
}
8687

87-
if calledExecPath != ".tools/bin/hashicorp/terraform/1.13.1/terraform" {
88-
t.Errorf("expected exec path '.tools/bin/hashicorp/terraform/1.13.1/terraform', got %s", calledExecPath)
88+
expected := filepath.FromSlash(".tools/bin/hashicorp/terraform/1.13.1/terraform")
89+
if calledExecPath != expected {
90+
t.Errorf("expected exec path %q, got %q", expected, calledExecPath)
8991
}
9092

9193
if calledExecArgs[1] != "--version" {

toolchain/installer.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,12 @@ func (i *Installer) extractZip(zipPath, binaryPath string, tool *Tool) error {
584584
return fmt.Errorf("failed to create temp dir: %w", err)
585585
}
586586
defer os.RemoveAll(tempDir)
587-
588-
cmd := exec.Command("unzip", "-o", zipPath, "-d", tempDir)
587+
var cmd *exec.Cmd
588+
if runtime.GOOS == "windows" {
589+
cmd = exec.Command("tar", "-xf", zipPath, "-C", tempDir)
590+
} else {
591+
cmd = exec.Command("unzip", "-o", zipPath, "-d", tempDir)
592+
}
589593
if output, err := cmd.CombinedOutput(); err != nil {
590594
var exitCode int
591595
// Case 1: Command ran but failed (non-zero exit)

0 commit comments

Comments
 (0)