couple of fixes

This commit is contained in:
maddalax 2024-09-26 11:47:16 -05:00
parent 22a9ef8659
commit 6b4ccf7604
3 changed files with 15 additions and 0 deletions

View file

@ -17,6 +17,12 @@ func HasFileFromRoot(file string) bool {
return err == nil return err == nil
} }
func CreateDirFromRoot(dir string) error {
cwd := process.GetWorkingDir()
path := filepath.Join(cwd, dir)
return os.MkdirAll(path, 0700)
}
func CopyDir(srcDir, dstDir string, predicate func(path string, exists bool) bool) error { func CopyDir(srcDir, dstDir string, predicate func(path string, exists bool) bool) error {
// Walk the source directory tree. // Walk the source directory tree.
return filepath.Walk(srcDir, func(srcPath string, info os.FileInfo, err error) error { return filepath.Walk(srcDir, func(srcPath string, info os.FileInfo, err error) error {

View file

@ -5,6 +5,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"github.com/maddalax/htmgo/cli/htmgo/internal" "github.com/maddalax/htmgo/cli/htmgo/internal"
"github.com/maddalax/htmgo/cli/htmgo/internal/dirutil"
"github.com/maddalax/htmgo/cli/htmgo/tasks/astgen" "github.com/maddalax/htmgo/cli/htmgo/tasks/astgen"
"github.com/maddalax/htmgo/cli/htmgo/tasks/copyassets" "github.com/maddalax/htmgo/cli/htmgo/tasks/copyassets"
"github.com/maddalax/htmgo/cli/htmgo/tasks/css" "github.com/maddalax/htmgo/cli/htmgo/tasks/css"
@ -56,6 +57,10 @@ func main() {
slog.Debug("Running task:", slog.String("task", taskName)) slog.Debug("Running task:", slog.String("task", taskName))
slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir())) slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir()))
if !dirutil.HasFileFromRoot("__htmgo") {
dirutil.CreateDirFromRoot("__htmgo")
}
if taskName == "watch" { if taskName == "watch" {
fmt.Printf("Running in watch mode\n") fmt.Printf("Running in watch mode\n")
os.Setenv("ENV", "development") os.Setenv("ENV", "development")

View file

@ -90,6 +90,10 @@ func downloadTailwindCli() {
filepath.Join(process.GetWorkingDir(), fileName), filepath.Join(process.GetWorkingDir(), fileName),
newPath) newPath)
if err != nil {
log.Fatalf("Error moving file: %s\n", err.Error())
}
if os != "windows" { if os != "windows" {
err = process.Run(process.NewRawCommand("chmod-tailwind-cli", err = process.Run(process.NewRawCommand("chmod-tailwind-cli",
fmt.Sprintf(`chmod +x %s`, newPath), fmt.Sprintf(`chmod +x %s`, newPath),