-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathmain.go
46 lines (42 loc) · 1.17 KB
/
main.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
45
46
//go:build js
// +build js
package main
import (
"path/filepath"
"syscall/js"
"github.com/hack-pad/hackpad/internal/global"
"github.com/hack-pad/hackpad/internal/interop"
"github.com/hack-pad/hackpad/internal/js/fs"
"github.com/hack-pad/hackpad/internal/js/process"
"github.com/hack-pad/hackpad/internal/log"
libProcess "github.com/hack-pad/hackpad/internal/process"
"github.com/hack-pad/hackpad/internal/terminal"
)
func main() {
process.Init()
fs.Init()
global.Set("spawnTerminal", js.FuncOf(terminal.SpawnTerminal))
global.Set("dump", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
go func() {
basePath := ""
if len(args) >= 1 {
basePath = args[0].String()
if filepath.IsAbs(basePath) {
basePath = filepath.Clean(basePath)
} else {
basePath = filepath.Join(libProcess.Current().WorkingDirectory(), basePath)
}
}
var fsDump interface{}
if basePath != "" {
fsDump = fs.Dump(basePath)
}
log.Error("Process:\n", process.Dump(), "\n\nFiles:\n", fsDump)
}()
return nil
}))
global.Set("profile", js.FuncOf(interop.ProfileJS))
global.Set("install", js.FuncOf(installFunc))
interop.SetInitialized()
select {}
}