Skip to content

Commit f8149e7

Browse files
authored
[envars] Add DEVBOX_WD env var (#2220)
## Summary Adds new `DEVBOX_WD` env var that can be used in scripts and shell. It has the original directory where the devbox command was called. It's useful when the script is directory specific. ## How was it tested? Added the following script: `"print-wd": "echo PWD=$PWD DEVBOX_WD=$DEVBOX_WD",`
1 parent 0623b13 commit f8149e7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/devbox/devbox.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,14 @@ func (d *Devbox) computeEnv(
704704
env["PATH"],
705705
)
706706

707+
wd, err := os.Getwd()
708+
if err != nil {
709+
return nil, err
710+
}
711+
707712
// Add helpful env vars for a Devbox project
708713
env["DEVBOX_PROJECT_ROOT"] = d.projectDir
714+
env["DEVBOX_WD"] = wd
709715
env["DEVBOX_CONFIG_DIR"] = d.projectDir + "/devbox.d"
710716
env["DEVBOX_PACKAGES_DIR"] = d.projectDir + "/" + nix.ProfilePath
711717

0 commit comments

Comments
 (0)