Skip to content

Commit

Permalink
cmd/mecha: replace wazero with fork on new project/module
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Mar 8, 2024
1 parent 7c71561 commit 9765213
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cmd/mecha/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ func createFromTemplate(templ, proj string) error {
os.Exit(1)
}

// patch the go.mod file to use forked wazero
basename := filepath.Base(proj)
if err := os.Chdir(basename); err != nil {
fmt.Println(err)
os.Exit(1)
}
defer os.Chdir("..")

return replaceWazeroWithFork()
}

func replaceWazeroWithFork() error {
var stdout, stderr bytes.Buffer
cmd := exec.Command("go", "mod", "edit", "-replace", "github.com/tetratelabs/wazero=github.com/orsinium-forks/[email protected]")
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
fmt.Printf("%s: %v\n%s%s", cmd.String(), err, stderr.Bytes(), stdout.Bytes())
os.Exit(1)
}

return nil
}

Expand Down

0 comments on commit 9765213

Please sign in to comment.