Skip to content

Commit

Permalink
Add ReplaceEnvVarsInString to path-utils.go
Browse files Browse the repository at this point in the history
  • Loading branch information
eye-wave committed Nov 20, 2023
1 parent 01fbdfb commit a01cdb5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils/path-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
)

func MigrateConfigFolder() {
Expand All @@ -24,6 +25,17 @@ func MigrateConfigFolder() {
}
}

func ReplaceEnvVarsInString(input string) string {
vars := os.Environ()
var replacements []string
for _, v := range vars {
pair := strings.SplitN(v, "=", 2)
replacements = append(replacements, "$"+pair[0], pair[1])
}
replacer := strings.NewReplacer(replacements...)
return replacer.Replace(input)
}

func GetSpicetifyFolder() string {
result, isAvailable := os.LookupEnv("SPICETIFY_CONFIG")
defer func() { CheckExistAndCreate(result) }()
Expand Down

0 comments on commit a01cdb5

Please sign in to comment.