commit
fc7e290682
3 changed files with 9 additions and 35 deletions
4
.github/FUNDING.yml
vendored
Normal file
4
.github/FUNDING.yml
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
kofi: goranbjelanovic
|
||||||
|
custom: ["https://mempool.space/address/bc1qtjhxe8mqx0yzff2l0f6stjpjj92kgwr0a53wxv", "https://etherscan.io/address/0xe98e4535C744c617e8E45828B63fDFf9367E3574"]
|
||||||
|
|
@ -4,11 +4,13 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-jet/jet/v2/internal/utils/filesys"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/go-jet/jet/v2/internal/utils/filesys"
|
||||||
|
|
||||||
"github.com/go-jet/jet/v2/generator/metadata"
|
"github.com/go-jet/jet/v2/generator/metadata"
|
||||||
"github.com/go-jet/jet/v2/internal/jet"
|
"github.com/go-jet/jet/v2/internal/jet"
|
||||||
)
|
)
|
||||||
|
|
@ -24,12 +26,11 @@ func ProcessSchema(dirPath string, schemaMetaData metadata.Schema, generatorTemp
|
||||||
|
|
||||||
fmt.Println("Destination directory:", schemaPath)
|
fmt.Println("Destination directory:", schemaPath)
|
||||||
fmt.Println("Cleaning up destination directory...")
|
fmt.Println("Cleaning up destination directory...")
|
||||||
err := filesys.RemoveDir(schemaPath)
|
if err := os.RemoveAll(schemaPath); err != nil {
|
||||||
if err != nil {
|
|
||||||
return errors.New("failed to cleanup generated files")
|
return errors.New("failed to cleanup generated files")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = processModel(schemaPath, schemaMetaData, schemaTemplate)
|
err := processModel(schemaPath, schemaMetaData, schemaTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to generate model types: %w", err)
|
return fmt.Errorf("failed to generate model types: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,34 +56,3 @@ func EnsureDirPathExist(dirPath string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveDir deletes everything at folder dir.
|
|
||||||
func RemoveDir(dir string) error {
|
|
||||||
exist, err := DirExists(dir)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if exist {
|
|
||||||
err := os.RemoveAll(dir)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DirExists checks if folder at path exist.
|
|
||||||
func DirExists(path string) (bool, error) {
|
|
||||||
_, err := os.Stat(path)
|
|
||||||
if err == nil {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return true, err
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue