()
| 42 | } |
| 43 | |
| 44 | func (v *VM) init() error { |
| 45 | initVarsForVm(v) |
| 46 | |
| 47 | // load scripts |
| 48 | entries, e := jsDir.ReadDir("js") |
| 49 | if e != nil { |
| 50 | return e |
| 51 | } |
| 52 | sort.Slice(entries, func(i, j int) bool { |
| 53 | return strings.Compare(entries[i].Name(), entries[j].Name()) < 0 |
| 54 | }) |
| 55 | for _, entry := range entries { |
| 56 | script, e := jsDir.ReadFile("js" + "/" + entry.Name()) |
| 57 | if e != nil { |
| 58 | return e |
| 59 | } |
| 60 | if _, e := v.Run(context.Background(), script); e != nil { |
| 61 | return e |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return nil |
| 66 | } |
| 67 | |
| 68 | func (v *VM) Set(name string, value any) { |
| 69 | v.o.Set(name, value) |
no test coverage detected