remove out folder if exists and add some logging
All checks were successful
ci/woodpecker/push/commit Pipeline was successful
All checks were successful
ci/woodpecker/push/commit Pipeline was successful
This commit is contained in:
parent
9edbc644d3
commit
db1c7eacc5
2 changed files with 6 additions and 1 deletions
7
main.go
7
main.go
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"embed"
|
"embed"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
|
@ -52,6 +53,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func action(ctx context.Context, cmd *cli.Command) error {
|
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)
|
os.MkdirAll(cmd.String("path"), 0755)
|
||||||
var files []wikipress.File
|
var files []wikipress.File
|
||||||
var err error
|
var err error
|
||||||
|
|
@ -75,7 +80,7 @@ func action(ctx context.Context, cmd *cli.Command) error {
|
||||||
if file.GetExtension() != "md" {
|
if file.GetExtension() != "md" {
|
||||||
err = wikipress.CreateFilePageAndCopyContent(file, cmd.String("out"))
|
err = wikipress.CreateFilePageAndCopyContent(file, cmd.String("out"))
|
||||||
if err != nil {
|
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()))
|
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 {
|
if err != nil {
|
||||||
|
|
|
||||||
BIN
wikipress
Executable file
BIN
wikipress
Executable file
Binary file not shown.
Loading…
Add table
Reference in a new issue