From be36e9bc56bb3a61badf89afa4e036baa7829519 Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Sun, 12 Apr 2020 13:56:28 +0300 Subject: [PATCH] Fix Issue with Being Unable to Create Config File --- cmd/root.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 924fee7..446f0bf 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -68,6 +68,7 @@ func initConfig() { utils.StdOutError(os.Stderr, "Error checking if config file exists: %s\n", err.Error()) os.Exit(1) } + cfgFile = configPath viper.SetConfigFile(configPath) } viper.Set(configs.GoogleOAuthClientIDConfigKey, GOOGLE_OAUTH_CLIENT_ID) @@ -75,7 +76,7 @@ func initConfig() { viper.AutomaticEnv() // @todo: improve error handling here, i.e fail if error is due to missing // config file - _ = viper.SafeWriteConfig() + _ = viper.SafeWriteConfigAs(cfgFile) // creates config file if doesn't exist // bind token flag to refresh token config, overriding incase token is supplied if err := viper.BindPFlag(configs.FirebaseRefreshTokenViperConfigKey, rootCmd.Flags().Lookup("token")); err != nil { utils.StdOutError(os.Stderr, "Error bind token flag: %s\n", err.Error())