1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

fix #115 - support toJson and toJSON (#116)

This commit is contained in:
Casey Lee 2020-02-28 15:20:31 -08:00 committed by GitHub
parent 85fde9ee94
commit 33561d42d3
2 changed files with 5 additions and 2 deletions

View file

@ -166,14 +166,16 @@ func vmJoin(vm *otto.Otto) {
}
func vmToJSON(vm *otto.Otto) {
_ = vm.Set("toJSON", func(o interface{}) string {
toJSON := func(o interface{}) string {
rtn, err := json.MarshalIndent(o, "", " ")
if err != nil {
logrus.Errorf("Unable to marsal: %v", err)
return ""
}
return string(rtn)
})
}
_ = vm.Set("toJSON", toJSON)
_ = vm.Set("toJson", toJSON)
}
func (rc *RunContext) vmHashFiles() func(*otto.Otto) {