feat: getting frontend dir, service binding

This commit is contained in:
2025-02-14 09:02:06 +07:00
parent d6825508e9
commit 013a3be72b
6 changed files with 48 additions and 13 deletions

View File

@@ -0,0 +1,30 @@
package utils
import (
"errors"
"os"
"slices"
"strings"
)
func FindFrontendPath() string {
currentPath, err := os.Getwd()
if err != nil {
panic(err)
}
dirs := strings.Split(currentPath, "\\")
if !slices.Contains(dirs, "frontend") {
panic(errors.New("Frontend dir doesn't exist"))
}
var path string
for i, dir := range dirs {
if dir == "frontend" {
break
}
if i > 0 {
dir = "/" + dir
}
path += dir
}
return path
}