Pi66

Home | Repos | About | Blog | Gaza

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

About | Files | Commits | Refs | License


feat: find project directory recursively

Author: pi66
Date: 2026-10-06 14:33
commit: 7b0d8172

Stat

M src/project/{main.go => project.go} 13 +12 -1

Diff

diff --git a/src/project/main.go b/src/project/project.go
similarity index 61%
rename from src/project/main.go
rename to src/project/project.go
index 8651a1e..bb2484a 100644
--- a/src/project/main.go
+++ b/src/project/project.go
@@ -2,6 +2,7 @@ package project

import ( "merodi/src/utils" + . "merodi/src/utils/errs" "merodi/src/utils/path" "os" "path/filepath" @@ -12,7 +13,17 @@ func SetProjectDir(args *[]string) (string, error) { if len(*args) > 0 { projectPath = utils.Pop(args, 0) } - return filepath.Abs(projectPath) ...

Show all

diff --git a/src/project/main.go b/src/project/project.go
similarity index 61%
rename from src/project/main.go
rename to src/project/project.go
index 8651a1e..bb2484a 100644
--- a/src/project/main.go
+++ b/src/project/project.go
@@ -2,6 +2,7 @@ package project

import ( "merodi/src/utils" + . "merodi/src/utils/errs" "merodi/src/utils/path" "os" "path/filepath" @@ -12,7 +13,17 @@ func SetProjectDir(args *[]string) (string, error) { if len(*args) > 0 { projectPath = utils.Pop(args, 0) } - return filepath.Abs(projectPath) + projectPath = CheckV(filepath.Abs(projectPath)) + + for projectPath != "/" { + if IsProjectExists(projectPath) { + return projectPath, nil + } + + projectPath = filepath.Dir(projectPath) + } + + return "", os.ErrNotExist }

func IsProjectExists(path string) bool {

// Created by Pi66

// Copyright ©Pi66 2026