-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathutils-php.go
44 lines (35 loc) · 937 Bytes
/
utils-php.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package common
import (
// "fmt"
"encoding/json"
"io/ioutil"
//"strings"
"regexp"
)
// Looks for node version in the package.json. If found returns true, version if not false, ""
func GetPHPVersion(composerJSONfile string) (bool, string) {
buf, err := ioutil.ReadFile(composerJSONfile)
if err != nil {
return false, err.Error()
}
var data map[string](interface{})
err = json.Unmarshal(buf, &data)
if err != nil {
return false, err.Error()
}
if data["require"] == nil {
return false, ""
}
if phpVersion, ok := data["require"].(map[string]interface{})["php"].(string); ok {
re := regexp.MustCompile("[0-9][.][0-9]")
return true, re.FindString(phpVersion)
} else {
return false, ""
}
}
func GetFramework(composerJSONfile string, framework string) (bool, string) {
return true, framework
}
func GetPHPDatabase(composerJSONfile string, databaseName string) (bool, string) {
return true, databaseName
}