From d03fb61247e26c3dec17ee4f9e6ca468e984185e Mon Sep 17 00:00:00 2001 From: Marcus Kok <47163063+Marcusk19@users.noreply.github.com> Date: Mon, 15 Apr 2024 08:56:25 -0400 Subject: [PATCH] recreate dotctl config when pulling from git (#28) --- cmd/sync.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmd/sync.go b/cmd/sync.go index eda56a5..d5d02b8 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "log" + "path" "time" "github.com/go-git/go-git/v5" @@ -170,5 +171,20 @@ func runSyncCommand(cmd *cobra.Command, args []string) { CheckIfError(err) } - viper.WriteConfig() + // a pull deletes the dotctl config from the filesystem, need to recreate it + fs := UseFilesystem() + err = fs.MkdirAll(path.Join(DotfilePath, "dotctl"), 0755) + if err != nil { + log.Fatalf("Unable to create dotfile structure: %s", error.Error(err)) + } + + _, err = fs.Create(path.Join(DotfilePath, "dotctl/config")) + if err != nil { + panic(fmt.Errorf("Unable to create config file %w", err)) + } + + err = viper.WriteConfig() + if err != nil { + fmt.Println("Error: could not write config: ", err) + } }