mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
parent
55bc366a8a
commit
0b4a9ceb31
|
@ -86,7 +86,6 @@ func executeUpgrade(latest string) {
|
|||
return
|
||||
}
|
||||
|
||||
fmt.Printf("\n❌ %s\n\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ func (m *model) Init() tea.Cmd {
|
|||
go func() {
|
||||
if err := install(m.tag); err != nil {
|
||||
m.error = err
|
||||
program.Quit()
|
||||
program.Send(resultMsg(fmt.Sprintf("❌ upgrade failed: %v", err)))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -132,11 +132,7 @@ func Run(latest string) error {
|
|||
title = titleStyle.Render(title)
|
||||
|
||||
program = tea.NewProgram(initialModel(latest))
|
||||
resultModel, err := program.Run()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resultModel, _ := program.Run()
|
||||
|
||||
programModel, OK := resultModel.(*model)
|
||||
if !OK {
|
||||
|
|
|
@ -2,6 +2,7 @@ package upgrade
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -16,6 +17,15 @@ func install(tag string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
targetDir := filepath.Dir(executable)
|
||||
fileName := filepath.Base(executable)
|
||||
|
||||
newPath := filepath.Join(targetDir, fmt.Sprintf(".%s.new", fileName))
|
||||
fp, err := os.OpenFile(newPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0775)
|
||||
if err != nil {
|
||||
return errors.New("we do not have permissions to update")
|
||||
}
|
||||
|
||||
setState(downloading)
|
||||
|
||||
data, err := downloadAndVerify(tag)
|
||||
|
@ -25,15 +35,6 @@ func install(tag string) error {
|
|||
|
||||
setState(installing)
|
||||
|
||||
targetDir := filepath.Dir(executable)
|
||||
fileName := filepath.Base(executable)
|
||||
|
||||
newPath := filepath.Join(targetDir, fmt.Sprintf(".%s.new", fileName))
|
||||
fp, err := os.OpenFile(newPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0775)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = io.Copy(fp, bytes.NewReader(data))
|
||||
// windows will have a lock when we do not close the file
|
||||
fp.Close()
|
||||
|
|
Loading…
Reference in a new issue