diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-10-11 19:53:56 +0200 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-10-11 19:53:56 +0200 |
| commit | a77e30e43fdca6caafe18c648d632496fd38eca0 (patch) | |
| tree | aab0040aa9dba4517962307762796338f21ac42f /js.go | |
| parent | 1fc497fbdc79a43c62ac2e8eaf4827752dbeef8e (diff) | |
Fix jsonprint output in dev mode
Diffstat (limited to 'js.go')
| -rw-r--r-- | js.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -9,10 +9,12 @@ import ( "errors" "fmt" "math/rand" + "os" "strings" "github.com/evanw/esbuild/pkg/api" "github.com/philippta/flyscrape/js" + "go.kuoruan.net/v8go-polyfills/console" v8 "rogchap.com/v8go" ) @@ -67,6 +69,11 @@ func build(src string) (string, error) { func vm(src string) (Config, ScrapeFunc, error) { ctx := v8.NewContext() + + if err := console.InjectTo(ctx, console.WithOutput(os.Stderr)); err != nil { + return nil, nil, fmt.Errorf("injecting console: %w", err) + } + ctx.RunScript("var module = {}", "main.js") if _, err := ctx.RunScript(removeIIFE(js.Flyscrape), "main.js"); err != nil { |