fix(windows): create unique installer

This commit is contained in:
Jan De Dobbeleer 2024-06-24 20:58:37 +02:00 committed by Jan De Dobbeleer
parent 197eaaa334
commit fa879a0ec2
2 changed files with 6 additions and 9 deletions

View file

@ -10,7 +10,7 @@ require (
github.com/alecthomas/repr v0.4.0 // indirect github.com/alecthomas/repr v0.4.0 // indirect
github.com/esimov/stackblur-go v1.1.0 github.com/esimov/stackblur-go v1.1.0
github.com/fogleman/gg v1.3.0 github.com/fogleman/gg v1.3.0
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0
github.com/gookit/color v1.5.4 github.com/gookit/color v1.5.4
github.com/huandu/xstrings v1.5.0 // indirect github.com/huandu/xstrings v1.5.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect

View file

@ -8,6 +8,8 @@ import (
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime" "runtime"
"github.com/google/uuid"
) )
var successMsg = "Oh My Posh is installing in the background.\nRestart your shell in a minute to take full advantage of the new functionality." var successMsg = "Oh My Posh is installing in the background.\nRestart your shell in a minute to take full advantage of the new functionality."
@ -20,14 +22,9 @@ func install() error {
return errors.New("failed to get TEMP environment variable") return errors.New("failed to get TEMP environment variable")
} }
path := filepath.Join(temp, "install.exe") id := uuid.New().String()
fileName := fmt.Sprintf("oh-my-posh-install-%s.exe", id)
if _, err := os.Stat(path); err == nil { path := filepath.Join(temp, fileName)
err := os.Remove(path)
if err != nil {
return errors.New("unable to remove existing installer")
}
}
file, err := os.Create(path) file, err := os.Create(path)
if err != nil { if err != nil {