Check pages and partials directories
This commit is contained in:
parent
16ec9400da
commit
82febc8670
1 changed files with 24 additions and 1 deletions
|
|
@ -5,7 +5,6 @@ import (
|
|||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"golang.org/x/mod/modfile"
|
||||
"io/fs"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
|
@ -14,6 +13,8 @@ import (
|
|||
"strings"
|
||||
"unicode"
|
||||
|
||||
"golang.org/x/mod/modfile"
|
||||
|
||||
"github.com/maddalax/htmgo/cli/htmgo/internal/dirutil"
|
||||
"github.com/maddalax/htmgo/cli/htmgo/tasks/process"
|
||||
"github.com/maddalax/htmgo/framework/h"
|
||||
|
|
@ -425,6 +426,22 @@ func HasModuleFile(path string) bool {
|
|||
return !os.IsNotExist(err)
|
||||
}
|
||||
|
||||
func CheckProjectDirectories(path string) error {
|
||||
pagesPath := filepath.Join(path, "pages")
|
||||
_, err := os.Stat(pagesPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("The directory pages does not exist.")
|
||||
}
|
||||
|
||||
partialsPath := filepath.Join(path, "partials")
|
||||
_, err = os.Stat(partialsPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("The directory partials does not exist.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeAssetsFile() {
|
||||
cwd := process.GetWorkingDir()
|
||||
config := dirutil.GetConfig()
|
||||
|
|
@ -494,6 +511,12 @@ func GetModuleName() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
checkDir := CheckProjectDirectories(wd)
|
||||
if checkDir != nil {
|
||||
fmt.Fprintf(os.Stderr, checkDir.Error())
|
||||
return ""
|
||||
}
|
||||
|
||||
goModBytes, err := os.ReadFile(modPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error reading go.mod: %v\n", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue