diff --git a/main.go b/main.go index 89b2c88..cbd7c36 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "context" "embed" + "errors" "fmt" "os" @@ -52,6 +53,10 @@ func main() { } func action(ctx context.Context, cmd *cli.Command) error { + if _, err := os.Stat(cmd.String("out")); !os.IsNotExist(err) { + log.Warn().Msg("Remove out folder") + os.RemoveAll(cmd.String("out")) + } os.MkdirAll(cmd.String("path"), 0755) var files []wikipress.File var err error @@ -75,7 +80,7 @@ func action(ctx context.Context, cmd *cli.Command) error { if file.GetExtension() != "md" { err = wikipress.CreateFilePageAndCopyContent(file, cmd.String("out")) if err != nil { - return err + return fmt.Errorf("%w: %s", errors.New("cant create file page and copy content"), err) } err = os.Symlink(fmt.Sprintf("./%v_%v.%v", file.GetName(), file.GetLastVersion().Hash, file.GetExtension()), fmt.Sprintf("%v/%v/%v.%v", cmd.String("out"), file.GetFolder(), file.GetName(), file.GetExtension())) if err != nil { diff --git a/wikipress b/wikipress new file mode 100755 index 0000000..a8547a7 Binary files /dev/null and b/wikipress differ