@@ -14,6 +14,8 @@ import (
1414 "github.com/mitchellh/go-homedir"
1515)
1616
17+ const InstallBaseDir = "/usr/local/bin"
18+
1719var GitFlowToolKitHome string
1820var InstallPath string
1921var HooksPath string
@@ -29,10 +31,10 @@ func init() {
2931 home , err := homedir .Dir ()
3032 CheckAndExit (err )
3133
32- GitFlowToolKitHome = home + string ( filepath . Separator ) + " .gitflow-toolkit"
33- InstallPath = GitFlowToolKitHome + string ( filepath . Separator ) + " gitflow-toolkit"
34- HooksPath = GitFlowToolKitHome + string ( filepath . Separator ) + " hooks"
35- GitCMHookPath = HooksPath + string ( filepath . Separator ) + " commit-msg"
34+ GitFlowToolKitHome = home + "/ .gitflow-toolkit"
35+ InstallPath = GitFlowToolKitHome + "/ gitflow-toolkit"
36+ HooksPath = GitFlowToolKitHome + "/ hooks"
37+ GitCMHookPath = HooksPath + "/ commit-msg"
3638
3739 CurrentPath , err = exec .LookPath (os .Args [0 ])
3840 CheckAndExit (err )
@@ -45,18 +47,18 @@ func init() {
4547func BinPaths () * []string {
4648 return & []string {
4749 GitCMHookPath ,
48- "/usr/local/bin /git-ci" ,
49- "/usr/local/bin /git-feat" ,
50- "/usr/local/bin /git-fix" ,
51- "/usr/local/bin /git-docs" ,
52- "/usr/local/bin /git-style" ,
53- "/usr/local/bin /git-refactor" ,
54- "/usr/local/bin /git-test" ,
55- "/usr/local/bin /git-chore" ,
56- "/usr/local/bin /git-perf" ,
57- "/usr/local/bin /git-hotfix" ,
58- "/usr/local/bin /git-xmr" ,
59- "/usr/local/bin /git-xpr" ,
50+ InstallBaseDir + " /git-ci" ,
51+ InstallBaseDir + " /git-feat" ,
52+ InstallBaseDir + " /git-fix" ,
53+ InstallBaseDir + " /git-docs" ,
54+ InstallBaseDir + " /git-style" ,
55+ InstallBaseDir + " /git-refactor" ,
56+ InstallBaseDir + " /git-test" ,
57+ InstallBaseDir + " /git-chore" ,
58+ InstallBaseDir + " /git-perf" ,
59+ InstallBaseDir + " /git-hotfix" ,
60+ InstallBaseDir + " /git-xmr" ,
61+ InstallBaseDir + " /git-xpr" ,
6062 }
6163}
6264
@@ -120,7 +122,10 @@ func OSEditInput() string {
120122
121123 f , err := ioutil .TempFile ("" , "gitflow-toolkit" )
122124 CheckAndExit (err )
123- defer os .Remove (f .Name ())
125+ defer func () {
126+ f .Close ()
127+ os .Remove (f .Name ())
128+ }()
124129
125130 // write utf8 bom
126131 bom := []byte {0xef , 0xbb , 0xbf }
@@ -140,9 +145,6 @@ func OSEditInput() string {
140145
141146 // 执行编辑文件
142147 cmd := exec .Command (editor , f .Name ())
143- cmd .Stdin = os .Stdin
144- cmd .Stdout = os .Stdout
145- cmd .Stderr = os .Stderr
146148 CheckAndExit (cmd .Run ())
147149 raw , err := ioutil .ReadFile (f .Name ())
148150 CheckAndExit (err )
0 commit comments