mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 19:10:35 +07:00
fix: windows
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FindFrontendPath() string {
|
func FindFrontendPath() string {
|
||||||
@@ -13,7 +13,7 @@ func FindFrontendPath() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dirs []string
|
var dirs []string
|
||||||
for currentPath != "/" {
|
for currentPath != filepath.VolumeName(currentPath)+string(os.PathSeparator) {
|
||||||
dir, file := filepath.Split(currentPath)
|
dir, file := filepath.Split(currentPath)
|
||||||
if file != "" {
|
if file != "" {
|
||||||
dirs = append([]string{file}, dirs...)
|
dirs = append([]string{file}, dirs...)
|
||||||
@@ -21,7 +21,7 @@ func FindFrontendPath() string {
|
|||||||
currentPath = filepath.Clean(dir)
|
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"))
|
panic(errors.New("You're not in frontend/src"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,13 +31,15 @@ func FindFrontendPath() string {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
dir = "/" + dir
|
path = filepath.Join(path, dir)
|
||||||
|
} else {
|
||||||
|
path = dir
|
||||||
}
|
}
|
||||||
path += dir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if dirs[0] == "home" {
|
if filepath.VolumeName(path) == "" {
|
||||||
path = "/" + path
|
path = filepath.Join(string(os.PathSeparator), path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user