@@ -12,7 +12,7 @@ import (
1212var PhpMap map [string ]string
1313
1414const (
15- PvmVersion = "0.0.1 "
15+ PvmVersion = "0.0.2 "
1616)
1717
1818func main () {
@@ -45,8 +45,8 @@ func getPhpMap() map[string]string {
4545
4646 PhpMap = make (map [string ]string )
4747 // 获取文件内容
48- if ! FileExists ("./php.txt" ) {
49- err := php2go .FilePutContents ("./php.txt" , "" , 0777 )
48+ if ! FileExists (confPath () ) {
49+ err := php2go .FilePutContents (confPath () , "" , 0777 )
5050 if err != nil {
5151 fmt .Println (err .Error ())
5252 return nil
@@ -64,14 +64,14 @@ func getPhpMap() map[string]string {
6464 return nil
6565 }
6666
67- err = php2go .FilePutContents ("./php.txt" , currentPhpVersion + " " + phpPath , 0777 )
67+ err = php2go .FilePutContents (confPath () , currentPhpVersion + " " + phpPath , 0777 )
6868 if err != nil {
6969 color .Red (err .Error ())
7070 return nil
7171 }
7272 }
7373
74- raw , err := ioutil .ReadFile ("./php.txt" )
74+ raw , err := ioutil .ReadFile (confPath () )
7575 if err != nil {
7676 color .Red ("php.txt can't read" )
7777 return nil
@@ -118,12 +118,17 @@ func lsPhp() {
118118 }
119119
120120 // 将新的 phpMap 写入 php.txt 中
121- err := php2go .FilePutContents ("./php.txt" , newPhpString , 0777 )
121+ err := php2go .FilePutContents (confPath () , newPhpString , 0777 )
122122 if err != nil {
123123 color .Red (err .Error ())
124124 }
125125}
126126
127+ // confPath conf file path
128+ func confPath () string {
129+ return InstallPath () + "/php.txt"
130+ }
131+
127132func addPhp (pPath string ) {
128133 phpExePath := pPath + "/php.exe"
129134 if ! FileExists (phpExePath ) {
@@ -149,7 +154,7 @@ func addPhp(pPath string) {
149154 }
150155 }
151156 newPhpString += phpVersion + " " + pPath + "\r \n "
152- err = php2go .FilePutContents ("./php.txt" , newPhpString , 0777 )
157+ err = php2go .FilePutContents (confPath () , newPhpString , 0777 )
153158 if err != nil {
154159 color .Red (err .Error ())
155160 }
@@ -182,9 +187,9 @@ func usePhp(key string) {
182187
183188func addSelfPath () {
184189 // todo 判断是否已经加入
185- currentPath := CurrentPath ()
190+ InstallPath := InstallPath ()
186191 // 将当前目录加入到运行环境中
187- err := addToEnv (currentPath )
192+ err := addToEnv (InstallPath )
188193 if err != nil {
189194 color .Red (err .Error ())
190195 }
0 commit comments