Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions commands/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ func Use(args []string) {
versionPath := filepath.Join(versionFolderPath, "php.exe")
versionPathCGI := filepath.Join(versionFolderPath, "php-cgi.exe")
composerPath := filepath.Join(versionFolderPath, "composer", "composer.phar")
envPHPFolder := "PHP_FOLDER=" + versionFolderPath

// create bat script for php
batCommand := "@echo off \n"
batCommand = batCommand + "set filepath=\"" + versionPath + "\"\n"
batCommand = batCommand + "set arguments=%*\n"
batCommand = batCommand + "%filepath% %arguments%\n"
batCommand += "set " + envPHPFolder + "\n"
batCommand += "set filepath=\"" + versionPath + "\"\n"
batCommand += "set arguments=%*\n"
batCommand += "%filepath% %arguments%\n"

err = os.WriteFile(batPath, []byte(batCommand), 0755)

Expand All @@ -139,8 +141,8 @@ func Use(args []string) {

// create sh script for php
shCommand := "#!/bin/bash\n"
shCommand = shCommand + "filepath=\"" + versionPath + "\"\n"
shCommand = shCommand + "\"$filepath\" \"$@\""
shCommand += "filepath=\"" + versionPath + "\"\n"
shCommand += envPHPFolder + " \"$filepath\" \"$@\""

err = os.WriteFile(shPath, []byte(shCommand), 0755)

Expand All @@ -150,9 +152,10 @@ func Use(args []string) {

// create bat script for php-cgi
batCommandCGI := "@echo off \n"
batCommandCGI = batCommandCGI + "set filepath=\"" + versionPathCGI + "\"\n"
batCommandCGI = batCommandCGI + "set arguments=%*\n"
batCommandCGI = batCommandCGI + "%filepath% %arguments%\n"
batCommandCGI += "set " + envPHPFolder + "\n"
batCommandCGI += "set filepath=\"" + versionPathCGI + "\"\n"
batCommandCGI += "set arguments=%*\n"
batCommandCGI += "%filepath% %arguments%\n"

err = os.WriteFile(batPathCGI, []byte(batCommandCGI), 0755)

Expand All @@ -162,8 +165,8 @@ func Use(args []string) {

// create sh script for php-cgi
shCommandCGI := "#!/bin/bash\n"
shCommandCGI = shCommandCGI + "filepath=\"" + versionPathCGI + "\"\n"
shCommandCGI = shCommandCGI + "\"$filepath\" \"$@\""
shCommandCGI += "filepath=\"" + versionPathCGI + "\"\n"
shCommandCGI += envPHPFolder + " \"$filepath\" \"$@\""

err = os.WriteFile(shPathCGI, []byte(shCommandCGI), 0755)

Expand Down