Skip to content

Commit

Permalink
fix: don't override NUV_PWD if already set
Browse files Browse the repository at this point in the history
  • Loading branch information
giusdp committed Jul 23, 2023
1 parent 4c20708 commit aa37e38
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ func main() {
log.SetFlags(0)
}

if pwd, err := os.Getwd(); err != nil {
warn("unable to set NUV_PWD to working directory", err)
} else {
os.Setenv("NUV_PWD", pwd)
}

// preflight checks
if err := preflightChecks(); err != nil {
log.Fatalf("[PREFLIGHT CHECK] error: %s", err.Error())
Expand All @@ -133,6 +127,7 @@ func main() {
}

setupTmp()
setupNuvPwd()
// first argument with prefix "-" is an embedded tool
// using "-" or "--" or "-task" invokes embedded task
args := os.Args
Expand Down Expand Up @@ -307,3 +302,11 @@ func runNuv(baseDir string, args []string) error {

return err
}

func setupNuvPwd() {
if os.Getenv("NUV_PWD") == "" {
dir, _ := os.Getwd()
//nolint:errcheck
os.Setenv("NUV_PWD", dir)
}
}

0 comments on commit aa37e38

Please sign in to comment.