mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -08:00
parent
96b3f01ae7
commit
cef5def472
|
@ -139,11 +139,11 @@ func (m *main) Init() tea.Cmd {
|
|||
return tea.Quit
|
||||
}
|
||||
|
||||
isZipFile := func() bool {
|
||||
return strings.HasSuffix(m.font, ".zip")
|
||||
isLocalZipFile := func() bool {
|
||||
return !strings.HasPrefix(m.font, "https") && strings.HasSuffix(m.font, ".zip")
|
||||
}
|
||||
|
||||
if len(m.font) != 0 && !isZipFile() {
|
||||
if len(m.font) != 0 && !isLocalZipFile() {
|
||||
m.state = downloadFont
|
||||
if !strings.HasPrefix(m.font, "https") {
|
||||
m.font = fmt.Sprintf("https://github.com/ryanoasis/nerd-fonts/releases/latest/download/%s.zip", m.font)
|
||||
|
@ -156,7 +156,7 @@ func (m *main) Init() tea.Cmd {
|
|||
}
|
||||
|
||||
defer func() {
|
||||
if isZipFile() {
|
||||
if isLocalZipFile() {
|
||||
go installLocalFontZIP(m.font)
|
||||
return
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ func (m *main) Init() tea.Cmd {
|
|||
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("170"))
|
||||
m.spinner = s
|
||||
m.state = getFonts
|
||||
if isZipFile() {
|
||||
if isLocalZipFile() {
|
||||
m.state = unzipFont
|
||||
}
|
||||
return m.spinner.Tick
|
||||
|
|
|
@ -58,7 +58,7 @@ func getRemoteFile(location string) (data []byte, err error) {
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return
|
||||
return data, fmt.Errorf("Failed to download zip file: %s\n→ %s", resp.Status, location)
|
||||
}
|
||||
|
||||
data, err = io.ReadAll(resp.Body)
|
||||
|
|
Loading…
Reference in a new issue