Skip to content

Commit

Permalink
Merge pull request #68 from warrensbox/master
Browse files Browse the repository at this point in the history
IMPORTANT: Fix bug that removes terraform from the path
  • Loading branch information
warrensbox authored Nov 14, 2019
2 parents 4cd5571 + 272db8a commit fba0e68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
16 changes: 16 additions & 0 deletions lib/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,19 @@ func CheckDirHasTGBin(dir, prefix string) bool {
}
return exist
}

//CheckDirExist : check if directory exist
//dir=path to file
//return path to directory
func CheckDirExist(dir string) bool {
if _, err := os.Stat(dir); os.IsNotExist(err) {
return false
}
return true
}

// Path : returns path of directory
// value=path to file
func Path(value string) string {
return filepath.Dir(value)
}
5 changes: 2 additions & 3 deletions lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"regexp"
"runtime"

"github.com/warrensbox/terraform-switcher/lib"
"github.com/warrensbox/tgswitch/modal"
)

Expand Down Expand Up @@ -67,8 +66,8 @@ func Install(url string, appversion string, assests []modal.Repo, userBinPath *s
installedBinPath = *userBinPath
}

pathDir := lib.Path(installedBinPath) //get path directory from binary path
binDirExist := lib.CheckDirExist(pathDir) //check bin path exist
pathDir := Path(installedBinPath) //get path directory from binary path
binDirExist := CheckDirExist(pathDir) //check bin path exist

if !binDirExist {
fmt.Printf("Binary path does not exist: %s\n", pathDir)
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
RELEASE_VERSION=0.3
RELEASE_VERSION=0.4

0 comments on commit fba0e68

Please sign in to comment.