Skip to content

Commit

Permalink
feat(uninstall): add os check
Browse files Browse the repository at this point in the history
add os check

Signed-off-by: mritd <[email protected]>
  • Loading branch information
mritd committed Jun 21, 2018
1 parent 7add5b9 commit fb80885
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
7 changes: 7 additions & 0 deletions pkg/util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,10 @@ func OSEditInput() string {

return input
}

func CheckOS() {
if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
fmt.Println("Platform not support!")
os.Exit(1)
}
}
46 changes: 20 additions & 26 deletions pkg/util/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,36 @@ import (
"fmt"
"io"
"os"
"runtime"
)

func Install() {

if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
Uninstall()

Uninstall()
fmt.Println("Install gitflow-toolkit")
fmt.Println("Create install home dir")
CheckAndExit(os.MkdirAll(GitFlowToolKitHome, 0755))

fmt.Println("Install gitflow-toolkit")
fmt.Println("Create install home dir")
CheckAndExit(os.MkdirAll(GitFlowToolKitHome, 0755))
fmt.Println("Copy file to install home")
currentFile, err := os.Open(CurrentPath)
CheckAndExit(err)
defer currentFile.Close()

fmt.Println("Copy file to install home")
currentFile, err := os.Open(CurrentPath)
defer currentFile.Close()
CheckAndExit(err)
installFile, err := os.OpenFile(InstallPath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0755)
CheckAndExit(err)
defer installFile.Close()

installFile, err := os.OpenFile(InstallPath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0755)
defer installFile.Close()
CheckAndExit(err)
_, err = io.Copy(installFile, currentFile)
CheckAndExit(err)
_, err = io.Copy(installFile, currentFile)
CheckAndExit(err)

fmt.Println("Create symbolic file")
CheckAndExit(os.MkdirAll(HooksPath, 0755))
fmt.Println("Create symbolic file")
CheckAndExit(os.MkdirAll(HooksPath, 0755))

for _, binPath := range *BinPaths() {
CheckAndExit(os.Symlink(InstallPath, binPath))
}
for _, binPath := range *BinPaths() {
CheckAndExit(os.Symlink(InstallPath, binPath))
}

fmt.Println("Config git")
MustExec("git", "config", "--global", "core.hooksPath", HooksPath)
fmt.Println("Config git")
MustExec("git", "config", "--global", "core.hooksPath", HooksPath)

} else {
fmt.Println("Platform not support!")
os.Exit(1)
}
}
1 change: 1 addition & 0 deletions pkg/util/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

func Uninstall() {

CheckOS()
CheckRoot()

fmt.Println("Uninstall gitflow-toolkit")
Expand Down

0 comments on commit fb80885

Please sign in to comment.