1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-19 05:27:57 +00:00
rolens/internal/app/app_environment.go

38 lines
739 B
Go
Raw Normal View History

2023-01-28 12:25:14 +00:00
package app
import (
"os/exec"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
type EnvironmentInfo struct {
Arch string `json:"arch"`
BuildType string `json:"buildType"`
Platform string `json:"platform"`
HasMongoExport bool `json:"hasMongoExport"`
HasMongoDump bool `json:"hasMongoDump"`
}
var env EnvironmentInfo
var envKnown = false
func (a *App) Environment() EnvironmentInfo {
if !envKnown {
wailsEnv := runtime.Environment(a.ctx)
env.Arch = wailsEnv.Arch
env.BuildType = wailsEnv.BuildType
env.Platform = wailsEnv.Platform
_, err := exec.LookPath("mongodump")
env.HasMongoDump = err == nil
_, err = exec.LookPath("mongoexport")
env.HasMongoExport = err == nil
envKnown = true
}
return env
}