mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 17:30:33 +07:00
36 lines
718 B
Go
36 lines
718 B
Go
package utils
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func FindFrontendPath() string {
|
|
currentPath, err := os.Getwd()
|
|
if err != nil {
|
|
log.Fatalf("Failed to find path for frontend: %s", err)
|
|
}
|
|
|
|
frontendSuffix := filepath.Join("frontend")
|
|
frontendSourceSuffix := filepath.Join("frontend", "src")
|
|
if strings.HasSuffix(currentPath, frontendSourceSuffix) {
|
|
return currentPath
|
|
}
|
|
|
|
var path string
|
|
|
|
if strings.HasSuffix(currentPath, frontendSuffix) {
|
|
path = filepath.Join(currentPath, "src")
|
|
} else {
|
|
path = filepath.Join(currentPath, frontendSourceSuffix)
|
|
}
|
|
|
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
|
log.Fatalf("Frontend source directory not found at %s", path)
|
|
}
|
|
|
|
return path
|
|
}
|