package linux

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")
	}
	return updates.InstallRoot{Path: filepath.Dir(app.ExecutablePath)}, nil
}
