Support .autoenv/.autoenv.leave alongside .env/.env.leade#268
Open
mrbitsdcf wants to merge 1 commit intohyperupcall:mainfrom
Open
Support .autoenv/.autoenv.leave alongside .env/.env.leade#268mrbitsdcf wants to merge 1 commit intohyperupcall:mainfrom
mrbitsdcf wants to merge 1 commit intohyperupcall:mainfrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds first-class support for the
.autoenvnaming convention, both when entering and leaving directories.Previously, autoenv only sourced
.envby default when entering a directory, and.env.leavewhen leaving a directory withAUTOENV_ENABLE_LEAVEenabled. This meant users who prefer the more explicit.autoenvnaming convention could not use it without custom configuration, and there was no matching.autoenv.leavedefault behavior.This change makes the default behavior support both naming styles:
Why
The
.autoenvfilename is clearer and less likely to conflict with other tooling that already treats.envas a dotenv/config file. Supporting.autoenvby default gives users a project-local shell hook name that more directly communicates that the file is executable autoenv behavior.Adding
.autoenv.leavecompletes that convention for cleanup hooks, so users do not need to mix.autoenvfor enter hooks with.env.leavefor leave hooks.What Changed
.autoenvalongside.env..autoenv.leavealongside.env.leave.AUTOENV_ENV_FILENAMEbehavior as a single custom filename override.AUTOENV_ENV_LEAVE_FILENAMEbehavior as a single custom filename override..autoenvbeing sourced by default..envand.autoenvboth being sourced.AUTOENV_ENV_FILENAMEpreserving the previous single-file override behavior..env.leaveand.autoenv.leaveboth being sourced when leave hooks are enabled.Compatibility
This should be backward compatible.
Existing users with
.envfiles continue to get the same behavior. Existing users with.env.leavefiles continue to get the same leave behavior whenAUTOENV_ENABLE_LEAVEis set.Users who set
AUTOENV_ENV_FILENAMEstill get only their configured filename, rather than the default.env/.autoenvpair. Likewise, users who setAUTOENV_ENV_LEAVE_FILENAMEstill get only their configured leave filename.Validation
I verified the shell syntax with:
I also ran focused behavior checks confirming that:
are both sourced on enter, and:
are both sourced on leave.
git diff --checkalso passes. The full shell suite could not be completed in my local environment becausezshwas not available, but the changed behavior is covered by focused tests.