From b00095e927a0003690ad01522e59b1b437638a0a Mon Sep 17 00:00:00 2001 From: Alexis Kulash Date: Wed, 27 Jan 2021 16:29:20 -0500 Subject: [PATCH 1/2] Stripping and replacing tildas to fix bug --- internal/cli/rules.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/cli/rules.go b/internal/cli/rules.go index a579d0b6c..24e5f98d3 100644 --- a/internal/cli/rules.go +++ b/internal/cli/rules.go @@ -489,8 +489,9 @@ func disableRule(rule *management.Rule, cli *cli) error { return cli.api.Rule.Update(rule.GetID(), &management.Rule{Enabled: auth0.Bool(false)}) } -// TODO: Fix tildas when passing relative filepaths, e.g. ~/Downloads/example.js func parseFileByName(inputFile string) (string, error) { + inputFile = strings.Replace(inputFile, "~/", "../", -1) + f, err := ioutil.ReadFile(inputFile) if err != nil { From a570cb56808270931a55f1ccf0f4a1dd763f0536 Mon Sep 17 00:00:00 2001 From: Alexis Kulash Date: Thu, 28 Jan 2021 10:50:42 -0500 Subject: [PATCH 2/2] Replacing package for better OS cross-compatibility --- internal/cli/rules.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/cli/rules.go b/internal/cli/rules.go index 24e5f98d3..b9fe38cc0 100644 --- a/internal/cli/rules.go +++ b/internal/cli/rules.go @@ -3,6 +3,7 @@ package cli import ( "fmt" "io/ioutil" + "os/user" "regexp" "strings" @@ -490,8 +491,8 @@ func disableRule(rule *management.Rule, cli *cli) error { } func parseFileByName(inputFile string) (string, error) { - inputFile = strings.Replace(inputFile, "~/", "../", -1) - + usr, _ := user.Current() + inputFile = strings.Replace(inputFile, "~/", usr.HomeDir+"/", -1) f, err := ioutil.ReadFile(inputFile) if err != nil {