-
Notifications
You must be signed in to change notification settings - Fork 260
Add --envrc-dir flag to allow specifying location of direnv config #2629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pstephan-geico-external
wants to merge
6
commits into
jetify-com:main
Choose a base branch
from
pstephan-geico-external:direnv-respect-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
415686e
Add --envrc-dir flag to allow specifying location of direnv config
pstephan-geico-external 6da0d57
Updates in response to code review
pstephan-geico-external df12f68
Corrected the allow command
pstephan-geico-external d005a8d
More review tweaks
pstephan-geico-external 8b57442
Cleanup in response to PR comments
pstephan-geico-external 928c344
More cleanup following review; config is no longer relative to .envrc
pstephan-geico-external File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Testscript to validate generating the contents of the .envrc file. | ||
# Note that since --envrc-dir was NOT specified, the .envrc will be in the `dir` directory and | ||
# the config will be found there, which means the `--print-env` doesn't need to specify the dir. | ||
# This matches the mode of operation prior to the addition of the --envrc-dir flag. | ||
|
||
mkdir dir | ||
exec devbox init dir | ||
exists dir/devbox.json | ||
|
||
exec devbox generate direnv --env x=y --config dir | ||
grep 'eval "\$\(devbox generate direnv --print-envrc --env x=y\)"' dir/.envrc | ||
|
||
cd dir | ||
exec devbox generate direnv --print-envrc --env x=y | ||
|
||
cmp stdout ../expected-results.txt | ||
|
||
# Note: The contents of the following file ends with two blank lines. This is | ||
# necessary to match the blank line that follows "use devbox" in the actual output. | ||
-- expected-results.txt -- | ||
use_devbox() { | ||
eval "$(devbox shellenv --init-hook --install --no-refresh-alias --env x=y )" | ||
watch_file $DEVBOX_PROJECT_ROOT/devbox.json $DEVBOX_PROJECT_ROOT/devbox.lock | ||
} | ||
use devbox | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Testscript to validate generating the contents of the .envrc file. | ||
# Note that since --envrc-dir was NOT specified, the .envrc will be in the `dir` directory and | ||
# the config will be found there, which means the `--print-env` doesn't need to specify the dir. | ||
# This matches the mode of operation prior to the addition of the --envrc-dir flag. | ||
|
||
mkdir dir | ||
exec devbox init dir | ||
exists dir/devbox.json | ||
|
||
exec devbox generate direnv --config dir | ||
grep 'eval "\$\(devbox generate direnv --print-envrc\)"' dir/.envrc | ||
|
||
cd dir | ||
exec devbox generate direnv --print-envrc | ||
|
||
cmp stdout ../expected-results.txt | ||
|
||
# Note: The contents of the following file ends with two blank lines. This is | ||
# necessary to match the blank line that follows "use devbox" in the actual output. | ||
-- expected-results.txt -- | ||
use_devbox() { | ||
eval "$(devbox shellenv --init-hook --install --no-refresh-alias)" | ||
watch_file $DEVBOX_PROJECT_ROOT/devbox.json $DEVBOX_PROJECT_ROOT/devbox.lock | ||
} | ||
use devbox | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Testscript to validate generating the contents of the .envrc file. | ||
|
||
exec devbox init | ||
exists devbox.json | ||
|
||
exec devbox generate direnv --env x=y | ||
grep 'eval "\$\(devbox generate direnv --print-envrc --env x=y\)"' .envrc | ||
|
||
exec devbox generate direnv --print-envrc --env x=y | ||
|
||
cmp stdout expected-results.txt | ||
|
||
# Note: The contents of the following file ends with two blank lines. This is | ||
# necessary to match the blank line that follows "use devbox" in the actual output. | ||
-- expected-results.txt -- | ||
use_devbox() { | ||
eval "$(devbox shellenv --init-hook --install --no-refresh-alias --env x=y )" | ||
watch_file $DEVBOX_PROJECT_ROOT/devbox.json $DEVBOX_PROJECT_ROOT/devbox.lock | ||
} | ||
use devbox | ||
|
27 changes: 27 additions & 0 deletions
27
testscripts/generate/direnv-envrcdir-config-parent.test.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Testscript to validate generating a direnv .envrc in a specified location (./dir). | ||
# The devbox config is in the current dir (parent to ./dir). Since no --config | ||
# is specified, the normal config-finding will find the config. | ||
|
||
exec devbox init | ||
exists ./devbox.json | ||
|
||
mkdir dir | ||
|
||
exec devbox generate direnv --envrc-dir dir | ||
grep 'eval "\$\(devbox generate direnv --print-envrc\)"' dir/.envrc | ||
! grep '--config' dir/.envrc # redundant, but making expectations obvious | ||
|
||
cd dir | ||
exec devbox generate direnv --print-envrc | ||
|
||
cmp stdout ../expected-results.txt | ||
|
||
# Note: The contents of the following file ends with two blank lines. This is | ||
# necessary to match the blank line that follows "use devbox" in the actual output. | ||
-- expected-results.txt -- | ||
use_devbox() { | ||
eval "$(devbox shellenv --init-hook --install --no-refresh-alias)" | ||
watch_file $DEVBOX_PROJECT_ROOT/devbox.json $DEVBOX_PROJECT_ROOT/devbox.lock | ||
} | ||
use devbox | ||
|
25 changes: 25 additions & 0 deletions
25
testscripts/generate/direnv-envrcdir-config-sibling.test.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Testscript to validate generating a direnv .envrc in a specified location (./dir) that also | ||
# references a devbox config in another dir (./cfg) that is a sibling to the first. | ||
|
||
mkdir cfg | ||
exec devbox init cfg | ||
exists cfg/devbox.json | ||
|
||
mkdir dir | ||
exec devbox generate direnv --envrc-dir dir --config cfg | ||
grep 'eval "\$\(devbox generate direnv --print-envrc --config ../cfg\)"' dir/.envrc | ||
|
||
cd dir | ||
exec devbox generate direnv --print-envrc --config ../cfg | ||
|
||
cmp stdout ../expected-results.txt | ||
|
||
# Note: The contents of the following file ends with two blank lines. This is | ||
# necessary to match the blank line that follows "use devbox" in the actual output. | ||
-- expected-results.txt -- | ||
use_devbox() { | ||
eval "$(devbox shellenv --init-hook --install --no-refresh-alias --config ../cfg)" | ||
watch_file $DEVBOX_PROJECT_ROOT/devbox.json $DEVBOX_PROJECT_ROOT/devbox.lock | ||
} | ||
use devbox | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.