mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 18:20:34 +07:00
29 lines
469 B
Go
29 lines
469 B
Go
package utils
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func FindFrontendPath() string {
|
|
currentPath, err := os.Getwd()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
dirs := strings.Split(currentPath, "\\")
|
|
if dirs[len(dirs) - 2] + "/" + dirs[len(dirs) - 1] != "frontend/src" {
|
|
panic(errors.New("You're not in frontend/src"))
|
|
}
|
|
var path string
|
|
for i, dir := range dirs {
|
|
if dir == "frontend" {
|
|
break
|
|
}
|
|
if i > 0 {
|
|
dir = "/" + dir
|
|
}
|
|
path += dir
|
|
}
|
|
return path
|
|
} |