@@ -4,42 +4,36 @@ import (
44 "fmt"
55 "io"
66 "os"
7- "runtime"
87)
98
109func Install () {
1110
12- if runtime . GOOS == "linux" || runtime . GOOS == "darwin" {
11+ Uninstall ()
1312
14- Uninstall ()
13+ fmt .Println ("Install gitflow-toolkit" )
14+ fmt .Println ("Create install home dir" )
15+ CheckAndExit (os .MkdirAll (GitFlowToolKitHome , 0755 ))
1516
16- fmt .Println ("Install gitflow-toolkit" )
17- fmt .Println ("Create install home dir" )
18- CheckAndExit (os .MkdirAll (GitFlowToolKitHome , 0755 ))
17+ fmt .Println ("Copy file to install home" )
18+ currentFile , err := os .Open (CurrentPath )
19+ CheckAndExit (err )
20+ defer currentFile .Close ()
1921
20- fmt .Println ("Copy file to install home" )
21- currentFile , err := os .Open (CurrentPath )
22- defer currentFile .Close ()
23- CheckAndExit (err )
22+ installFile , err := os .OpenFile (InstallPath , os .O_CREATE | os .O_RDWR | os .O_TRUNC , 0755 )
23+ CheckAndExit (err )
24+ defer installFile .Close ()
2425
25- installFile , err := os .OpenFile (InstallPath , os .O_CREATE | os .O_RDWR | os .O_TRUNC , 0755 )
26- defer installFile .Close ()
27- CheckAndExit (err )
28- _ , err = io .Copy (installFile , currentFile )
29- CheckAndExit (err )
26+ _ , err = io .Copy (installFile , currentFile )
27+ CheckAndExit (err )
3028
31- fmt .Println ("Create symbolic file" )
32- CheckAndExit (os .MkdirAll (HooksPath , 0755 ))
29+ fmt .Println ("Create symbolic file" )
30+ CheckAndExit (os .MkdirAll (HooksPath , 0755 ))
3331
34- for _ , binPath := range * BinPaths () {
35- CheckAndExit (os .Symlink (InstallPath , binPath ))
36- }
32+ for _ , binPath := range * BinPaths () {
33+ CheckAndExit (os .Symlink (InstallPath , binPath ))
34+ }
3735
38- fmt .Println ("Config git" )
39- MustExec ("git" , "config" , "--global" , "core.hooksPath" , HooksPath )
36+ fmt .Println ("Config git" )
37+ MustExec ("git" , "config" , "--global" , "core.hooksPath" , HooksPath )
4038
41- } else {
42- fmt .Println ("Platform not support!" )
43- os .Exit (1 )
44- }
4539}
0 commit comments