@@ -12,7 +12,7 @@ import (
12
12
var PhpMap map [string ]string
13
13
14
14
const (
15
- PvmVersion = "0.0.1 "
15
+ PvmVersion = "0.0.2 "
16
16
)
17
17
18
18
func main () {
@@ -45,8 +45,8 @@ func getPhpMap() map[string]string {
45
45
46
46
PhpMap = make (map [string ]string )
47
47
// 获取文件内容
48
- if ! FileExists ("./php.txt" ) {
49
- err := php2go .FilePutContents ("./php.txt" , "" , 0777 )
48
+ if ! FileExists (confPath () ) {
49
+ err := php2go .FilePutContents (confPath () , "" , 0777 )
50
50
if err != nil {
51
51
fmt .Println (err .Error ())
52
52
return nil
@@ -64,14 +64,14 @@ func getPhpMap() map[string]string {
64
64
return nil
65
65
}
66
66
67
- err = php2go .FilePutContents ("./php.txt" , currentPhpVersion + " " + phpPath , 0777 )
67
+ err = php2go .FilePutContents (confPath () , currentPhpVersion + " " + phpPath , 0777 )
68
68
if err != nil {
69
69
color .Red (err .Error ())
70
70
return nil
71
71
}
72
72
}
73
73
74
- raw , err := ioutil .ReadFile ("./php.txt" )
74
+ raw , err := ioutil .ReadFile (confPath () )
75
75
if err != nil {
76
76
color .Red ("php.txt can't read" )
77
77
return nil
@@ -118,12 +118,17 @@ func lsPhp() {
118
118
}
119
119
120
120
// 将新的 phpMap 写入 php.txt 中
121
- err := php2go .FilePutContents ("./php.txt" , newPhpString , 0777 )
121
+ err := php2go .FilePutContents (confPath () , newPhpString , 0777 )
122
122
if err != nil {
123
123
color .Red (err .Error ())
124
124
}
125
125
}
126
126
127
+ // confPath conf file path
128
+ func confPath () string {
129
+ return InstallPath () + "/php.txt"
130
+ }
131
+
127
132
func addPhp (pPath string ) {
128
133
phpExePath := pPath + "/php.exe"
129
134
if ! FileExists (phpExePath ) {
@@ -149,7 +154,7 @@ func addPhp(pPath string) {
149
154
}
150
155
}
151
156
newPhpString += phpVersion + " " + pPath + "\r \n "
152
- err = php2go .FilePutContents ("./php.txt" , newPhpString , 0777 )
157
+ err = php2go .FilePutContents (confPath () , newPhpString , 0777 )
153
158
if err != nil {
154
159
color .Red (err .Error ())
155
160
}
@@ -182,9 +187,9 @@ func usePhp(key string) {
182
187
183
188
func addSelfPath () {
184
189
// todo 判断是否已经加入
185
- currentPath := CurrentPath ()
190
+ InstallPath := InstallPath ()
186
191
// 将当前目录加入到运行环境中
187
- err := addToEnv (currentPath )
192
+ err := addToEnv (InstallPath )
188
193
if err != nil {
189
194
color .Red (err .Error ())
190
195
}
0 commit comments