chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package workspaceruntime
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"inbox/internal/app/lanegit"
|
||||
)
|
||||
|
||||
type hostInboxBinary struct {
|
||||
projectRoot string
|
||||
runner lanegit.Runner
|
||||
}
|
||||
|
||||
func (b *hostInboxBinary) ensure(ctx context.Context) (string, error) {
|
||||
binaryPath := filepath.Join(b.projectRoot, ".runtime", "bin", "inbox")
|
||||
needsBuild, err := b.needsBuild(binaryPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !needsBuild {
|
||||
return binaryPath, nil
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Dir(binaryPath), 0755); err != nil {
|
||||
return "", fmt.Errorf("create runtime bin dir: %w", err)
|
||||
}
|
||||
env := map[string]string{
|
||||
"GOOS": "linux",
|
||||
"GOARCH": runtime.GOARCH,
|
||||
}
|
||||
out, err := b.runner.Run(ctx, filepath.Join(b.projectRoot, "inbox"), env, "go", "build", "-o", binaryPath, "./cmd/inbox")
|
||||
if err != nil {
|
||||
return "", commandError("build inbox binary", out, err)
|
||||
}
|
||||
return binaryPath, nil
|
||||
}
|
||||
|
||||
func (b *hostInboxBinary) needsBuild(binaryPath string) (bool, error) {
|
||||
return sourceTreeNeedsBuild(b.projectRoot, "inbox", binaryPath)
|
||||
}
|
||||
Reference in New Issue
Block a user