1
0
Fork 0

Adding upstream version 0.0~git20250409.f7acab6.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-22 11:36:18 +02:00
parent b9b5d88025
commit 21b930d007
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
51 changed files with 11229 additions and 0 deletions

37
process/module.go Normal file
View file

@ -0,0 +1,37 @@
package process
import (
"os"
"strings"
"github.com/dop251/goja"
"github.com/dop251/goja_nodejs/require"
)
const ModuleName = "process"
type Process struct {
env map[string]string
}
func Require(runtime *goja.Runtime, module *goja.Object) {
p := &Process{
env: make(map[string]string),
}
for _, e := range os.Environ() {
envKeyValue := strings.SplitN(e, "=", 2)
p.env[envKeyValue[0]] = envKeyValue[1]
}
o := module.Get("exports").(*goja.Object)
o.Set("env", p.env)
}
func Enable(runtime *goja.Runtime) {
runtime.Set("process", require.Require(runtime, ModuleName))
}
func init() {
require.RegisterCoreModule(ModuleName, Require)
}