From f11e67e0916cdcd15a04df9d11365a3b32511d0c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 28 Nov 2024 17:56:12 +0100 Subject: [PATCH] Fix path on local envs --- envs/local.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/envs/local.go b/envs/local.go index 2eee8089..b687f7c8 100644 --- a/envs/local.go +++ b/envs/local.go @@ -48,7 +48,7 @@ func NewLocal(path string, debug bool) (*Local, error) { return nil, errors.WithStack(err) } return &Local{ - Dir: path, + Dir: guessProjectDir(path), Debug: debug, }, nil } @@ -283,3 +283,20 @@ func (l *Local) webServer() Envs { return env } + +func guessProjectDir(dir string) string { + for { + f, err := os.Stat(filepath.Join(dir, ".git")) + if err == nil && f.IsDir() { + return dir + } + + upDir := filepath.Dir(dir) + if upDir == dir || upDir == "." { + break + } + dir = upDir + } + + return "" +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy