Skip to content

Commit

Permalink
Add log messages to installation process
Browse files Browse the repository at this point in the history
  • Loading branch information
spachava753 committed Sep 14, 2023
1 parent 25e2336 commit ec5dca2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/tool/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ func Install(
binary = binary + ".exe"
}

fmt.Printf("installing %s...\n", binary)

// check that the version exists
fmt.Println("verifying version info")
versions, err := b.Versions(max)
if err != nil {
return "", err
Expand Down Expand Up @@ -81,14 +84,17 @@ func Install(
binaryLinkPath := filepath.Join(basePath, "bin", binary)

// check if installed already
fmt.Println("checking for local installation")
installed, err := Installed(basePath, binary, version)
if err != nil {
return "", err
}

if installed {
// since we already have it installed, set the symlink to this
fmt.Println("tool already installed!")
if !force {
fmt.Println("setting symlink")
if err = os.Remove(binaryLinkPath); err != nil {
if !os.IsNotExist(err) {
return "", fmt.Errorf(
Expand All @@ -102,6 +108,7 @@ func Install(
)
}
// since force is enabled, remove the file and continue
fmt.Println("removing local installation")
if err := os.Remove(binaryPath); err != nil {
return "", err
}
Expand All @@ -114,6 +121,7 @@ func Install(
}

// download CLI
fmt.Println("downloading from tool from ", url)
tmpFilePath, err := f.FetchFile(url)
if err != nil {
return "", err
Expand All @@ -125,6 +133,7 @@ func Install(
}
}()

fmt.Println("extracting...")
tmpFilePath, err = b.Extract(tmpFilePath, version)
if err != nil {
return "", err
Expand All @@ -134,6 +143,7 @@ func Install(
}

// copy to our bin path
fmt.Println("installing...")
// create binary file
if _, err := os.Stat(binaryVersionPath); os.IsNotExist(err) {
if err := os.MkdirAll(binaryVersionPath, os.ModePerm); err != nil {
Expand Down

0 comments on commit ec5dca2

Please sign in to comment.