feat: initial commit
This commit is contained in:
12
pkg/wails3kit/updates/platform/darwin/BUILD.bazel
Normal file
12
pkg/wails3kit/updates/platform/darwin/BUILD.bazel
Normal file
@@ -0,0 +1,12 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "darwin",
|
||||
srcs = ["darwin.go"],
|
||||
importpath = "github.com/Eriyc/rules_wails/pkg/wails3kit/updates/platform/darwin",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/wails3kit/updates",
|
||||
"//pkg/wails3kit/updates/platform",
|
||||
],
|
||||
)
|
||||
31
pkg/wails3kit/updates/platform/darwin/darwin.go
Normal file
31
pkg/wails3kit/updates/platform/darwin/darwin.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package darwin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Eriyc/rules_wails/pkg/wails3kit/updates"
|
||||
"github.com/Eriyc/rules_wails/pkg/wails3kit/updates/platform"
|
||||
)
|
||||
|
||||
func New() updates.PlatformInstaller {
|
||||
return platform.New(DetectInstallRoot)
|
||||
}
|
||||
|
||||
func DetectInstallRoot(app updates.AppDescriptor) (updates.InstallRoot, error) {
|
||||
if app.ExecutablePath == "" {
|
||||
return updates.InstallRoot{}, errors.New("missing executable path")
|
||||
}
|
||||
|
||||
current := filepath.Dir(app.ExecutablePath)
|
||||
for {
|
||||
if filepath.Ext(current) == ".app" {
|
||||
return updates.InstallRoot{Path: current}, nil
|
||||
}
|
||||
parent := filepath.Dir(current)
|
||||
if parent == current {
|
||||
return updates.InstallRoot{}, errors.New("unable to locate .app bundle")
|
||||
}
|
||||
current = parent
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user