File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -49,20 +49,27 @@ func runInitCommand(cmd *cobra.Command, args []string) {
4949 if destDir == "" {
5050 destDir = viper .GetString ("directories.Data" )
5151 }
52- logrus .Infof ("Writing config file to: %s" , destDir )
5352
54- if err := os .MkdirAll (destDir , os .FileMode (0755 )); err != nil {
53+ absPath , err := filepath .Abs (destDir )
54+ if err != nil {
55+ feedback .Errorf ("Cannot find absolute path: %v" , err )
56+ os .Exit (errorcodes .ErrGeneric )
57+ }
58+ configFileAbsPath := filepath .Join (absPath , defaultFileName )
59+
60+ logrus .Infof ("Writing config file to: %s" , absPath )
61+
62+ if err := os .MkdirAll (absPath , os .FileMode (0755 )); err != nil {
5563 feedback .Errorf ("Cannot create config file directory: %v" , err )
5664 os .Exit (errorcodes .ErrGeneric )
5765 }
5866
59- configFile := filepath .Join (destDir , defaultFileName )
60- if err := viper .WriteConfigAs (configFile ); err != nil {
67+ if err := viper .WriteConfigAs (configFileAbsPath ); err != nil {
6168 feedback .Errorf ("Cannot create config file: %v" , err )
6269 os .Exit (errorcodes .ErrGeneric )
6370 }
6471
65- msg := "Config file written to: " + configFile
72+ msg := "Config file written to: " + configFileAbsPath
6673 logrus .Info (msg )
6774 feedback .Print (msg )
6875}
You can’t perform that action at this time.
0 commit comments