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