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/ast"
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/token"
|
"go/token"
|
||||||
"golang.org/x/mod/modfile"
|
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -14,6 +13,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
|
"golang.org/x/mod/modfile"
|
||||||
|
|
||||||
"github.com/maddalax/htmgo/cli/htmgo/internal/dirutil"
|
"github.com/maddalax/htmgo/cli/htmgo/internal/dirutil"
|
||||||
"github.com/maddalax/htmgo/cli/htmgo/tasks/process"
|
"github.com/maddalax/htmgo/cli/htmgo/tasks/process"
|
||||||
"github.com/maddalax/htmgo/framework/h"
|
"github.com/maddalax/htmgo/framework/h"
|
||||||
|
|
@ -425,6 +426,22 @@ func HasModuleFile(path string) bool {
|
||||||
return !os.IsNotExist(err)
|
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() {
|
func writeAssetsFile() {
|
||||||
cwd := process.GetWorkingDir()
|
cwd := process.GetWorkingDir()
|
||||||
config := dirutil.GetConfig()
|
config := dirutil.GetConfig()
|
||||||
|
|
@ -494,6 +511,12 @@ func GetModuleName() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkDir := CheckProjectDirectories(wd)
|
||||||
|
if checkDir != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, checkDir.Error())
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
goModBytes, err := os.ReadFile(modPath)
|
goModBytes, err := os.ReadFile(modPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error reading go.mod: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error reading go.mod: %v\n", err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue