Rename packages
This commit is contained in:
parent
49b8760527
commit
ef1243ea39
47 changed files with 524 additions and 369 deletions
33
internal/config/executable.go
Normal file
33
internal/config/executable.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/core"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
|
||||
)
|
||||
|
||||
// ExecutablePath returns the path to the executable of this distillery.
|
||||
func (cfg Config) ExecutablePath() string {
|
||||
return filepath.Join(cfg.DeployRoot, core.Executable)
|
||||
}
|
||||
|
||||
// UsingDistilleryExecutable checks if the current process is using the distillery executable
|
||||
func (cfg Config) UsingDistilleryExecutable() bool {
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return fsx.SameFile(exe, cfg.ExecutablePath())
|
||||
}
|
||||
|
||||
// CurrentExecutable returns the path to the current executable being used.
|
||||
// When it does not exist, falls back to the default executable.
|
||||
func (cfg Config) CurrentExecutable() string {
|
||||
exe, err := os.Executable()
|
||||
if err != nil || !fsx.IsFile(exe) {
|
||||
return cfg.ExecutablePath()
|
||||
}
|
||||
return exe
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue