Skip to content

Support .autoenv/.autoenv.leave alongside .env/.env.leade#268

Open
mrbitsdcf wants to merge 1 commit intohyperupcall:mainfrom
mrbitsdcf:mrbits-dot-autoenv-file-support
Open

Support .autoenv/.autoenv.leave alongside .env/.env.leade#268
mrbitsdcf wants to merge 1 commit intohyperupcall:mainfrom
mrbitsdcf:mrbits-dot-autoenv-file-support

Conversation

@mrbitsdcf
Copy link
Copy Markdown

This PR adds first-class support for the .autoenv naming convention, both when entering and leaving directories.

Previously, autoenv only sourced .env by default when entering a directory, and .env.leave when leaving a directory with AUTOENV_ENABLE_LEAVE enabled. This meant users who prefer the more explicit .autoenv naming convention could not use it without custom configuration, and there was no matching .autoenv.leave default behavior.

This change makes the default behavior support both naming styles:

.env              runs when entering
.autoenv          runs when entering

.env.leave        runs when leaving
.autoenv.leave    runs when leaving

Why

The .autoenv filename is clearer and less likely to conflict with other tooling that already treats .env as a dotenv/config file. Supporting .autoenv by default gives users a project-local shell hook name that more directly communicates that the file is executable autoenv behavior.

Adding .autoenv.leave completes that convention for cleanup hooks, so users do not need to mix .autoenv for enter hooks with .env.leave for leave hooks.

What Changed

  • Added default support for .autoenv alongside .env.
  • Added default support for .autoenv.leave alongside .env.leave.
  • Preserved existing AUTOENV_ENV_FILENAME behavior as a single custom filename override.
  • Preserved existing AUTOENV_ENV_LEAVE_FILENAME behavior as a single custom filename override.
  • Updated README documentation to describe the new default filenames.
  • Added tests for:
    • .autoenv being sourced by default.
    • .env and .autoenv both being sourced.
    • custom AUTOENV_ENV_FILENAME preserving the previous single-file override behavior.
    • .env.leave and .autoenv.leave both being sourced when leave hooks are enabled.

Compatibility

This should be backward compatible.

Existing users with .env files continue to get the same behavior. Existing users with .env.leave files continue to get the same leave behavior when AUTOENV_ENABLE_LEAVE is set.

Users who set AUTOENV_ENV_FILENAME still get only their configured filename, rather than the default .env / .autoenv pair. Likewise, users who set AUTOENV_ENV_LEAVE_FILENAME still get only their configured leave filename.

Validation

I verified the shell syntax with:

sh -n activate.sh
bash -n activate.sh

I also ran focused behavior checks confirming that:

.env + .autoenv

are both sourced on enter, and:

.env.leave + .autoenv.leave

are both sourced on leave.

git diff --check also passes. The full shell suite could not be completed in my local environment because zsh was not available, but the changed behavior is covered by focused tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant