diff --git a/cli/htmgo/internal/dirutil/dir.go b/cli/htmgo/internal/dirutil/dir.go index 97ba191..0fcc84c 100644 --- a/cli/htmgo/internal/dirutil/dir.go +++ b/cli/htmgo/internal/dirutil/dir.go @@ -17,6 +17,12 @@ func HasFileFromRoot(file string) bool { 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 { // Walk the source directory tree. return filepath.Walk(srcDir, func(srcPath string, info os.FileInfo, err error) error { diff --git a/cli/htmgo/runner.go b/cli/htmgo/runner.go index ab27c44..075a4d7 100644 --- a/cli/htmgo/runner.go +++ b/cli/htmgo/runner.go @@ -5,6 +5,7 @@ import ( "flag" "fmt" "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/copyassets" "github.com/maddalax/htmgo/cli/htmgo/tasks/css" @@ -56,6 +57,10 @@ func main() { slog.Debug("Running task:", slog.String("task", taskName)) slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir())) + if !dirutil.HasFileFromRoot("__htmgo") { + dirutil.CreateDirFromRoot("__htmgo") + } + if taskName == "watch" { fmt.Printf("Running in watch mode\n") os.Setenv("ENV", "development") diff --git a/cli/htmgo/tasks/css/css.go b/cli/htmgo/tasks/css/css.go index ba41f1c..0bdaf58 100644 --- a/cli/htmgo/tasks/css/css.go +++ b/cli/htmgo/tasks/css/css.go @@ -90,6 +90,10 @@ func downloadTailwindCli() { filepath.Join(process.GetWorkingDir(), fileName), newPath) + if err != nil { + log.Fatalf("Error moving file: %s\n", err.Error()) + } + if os != "windows" { err = process.Run(process.NewRawCommand("chmod-tailwind-cli", fmt.Sprintf(`chmod +x %s`, newPath),