mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 16:30:33 +07:00
feat: getting frontend dir, service binding
This commit is contained in:
30
utils/find_frontend_path.go
Normal file
30
utils/find_frontend_path.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user