From cd197abd9046661c0d46d574edf7ea984876d3d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D1=81=D0=B8=D0=BB=D0=B8=D0=B9=20=D0=98=D0=BB?= =?UTF-8?q?=D0=BB=D0=B0=D1=80=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2=D0=B8=D1=87?= Date: Thu, 20 Feb 2025 12:18:40 +0700 Subject: [PATCH] fix: windows --- utils/find_frontend_path.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/utils/find_frontend_path.go b/utils/find_frontend_path.go index 5b787c3..78dfa29 100644 --- a/utils/find_frontend_path.go +++ b/utils/find_frontend_path.go @@ -1,9 +1,9 @@ package utils import ( - "errors" - "os" - "path/filepath" + "errors" + "os" + "path/filepath" ) func FindFrontendPath() string { @@ -13,7 +13,7 @@ func FindFrontendPath() string { } var dirs []string - for currentPath != "/" { + for currentPath != filepath.VolumeName(currentPath)+string(os.PathSeparator) { dir, file := filepath.Split(currentPath) if file != "" { dirs = append([]string{file}, dirs...) @@ -21,7 +21,7 @@ func FindFrontendPath() string { currentPath = filepath.Clean(dir) } - if len(dirs) < 2 || dirs[len(dirs)-2] + "/" + dirs[len(dirs)-1] != "frontend/src" { + if len(dirs) < 2 || filepath.Join(dirs[len(dirs)-2], dirs[len(dirs)-1]) != filepath.Join("frontend", "src") { panic(errors.New("You're not in frontend/src")) } @@ -31,13 +31,15 @@ func FindFrontendPath() string { break } if i > 0 { - dir = "/" + dir + path = filepath.Join(path, dir) + } else { + path = dir } - path += dir } - if dirs[0] == "home" { - path = "/" + path + if filepath.VolumeName(path) == "" { + path = filepath.Join(string(os.PathSeparator), path) } + return path } \ No newline at end of file