File tree 1 file changed +12
-5
lines changed
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) {
49
49
if destDir == "" {
50
50
destDir = viper .GetString ("directories.Data" )
51
51
}
52
- logrus .Infof ("Writing config file to: %s" , destDir )
53
52
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 {
55
63
feedback .Errorf ("Cannot create config file directory: %v" , err )
56
64
os .Exit (errorcodes .ErrGeneric )
57
65
}
58
66
59
- configFile := filepath .Join (destDir , defaultFileName )
60
- if err := viper .WriteConfigAs (configFile ); err != nil {
67
+ if err := viper .WriteConfigAs (configFileAbsPath ); err != nil {
61
68
feedback .Errorf ("Cannot create config file: %v" , err )
62
69
os .Exit (errorcodes .ErrGeneric )
63
70
}
64
71
65
- msg := "Config file written to: " + configFile
72
+ msg := "Config file written to: " + configFileAbsPath
66
73
logrus .Info (msg )
67
74
feedback .Print (msg )
68
75
}
You can’t perform that action at this time.
0 commit comments