Skip to content

Commit

Permalink
fix home variable in config (#73)
Browse files Browse the repository at this point in the history
fix: home variable in config
  • Loading branch information
metafates authored Aug 16, 2022
1 parent baa3ff5 commit 61928e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ chapter_name_template = '[{padded-index}] {chapter}'
# Absolute or relative.
#
# You can also use home variable
# Linux/macOS = $HOME or ~
# Windows = %USERPROFILE%
# path = "~/..." or "$HOME/..."
path = '.'

# Use asynchronous downloader (faster)
Expand Down
14 changes: 4 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/samber/lo"
"github.com/spf13/viper"
"os"
"runtime"
"strings"
)

Expand Down Expand Up @@ -108,13 +107,8 @@ func resolveAliases() {
home := lo.Must(os.UserHomeDir())
path := viper.GetString(DownloaderPath)

switch runtime.GOOS {
case "windows":
path = strings.ReplaceAll(path, "%USERPROFILE%", home)
case "darwin", "linux":
path = strings.ReplaceAll(path, "$HOME", home)
path = strings.ReplaceAll(path, "~", home)
default:
panic("unsupported OS: " + runtime.GOOS)
}
path = strings.ReplaceAll(path, "$HOME", home)
path = strings.ReplaceAll(path, "~", home)

viper.Set(DownloaderPath, path)
}
2 changes: 1 addition & 1 deletion constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package constant

const (
Mangal = "mangal"
Version = "3.2.0"
Version = "3.2.1"
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
)

Expand Down

0 comments on commit 61928e5

Please sign in to comment.