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