Feature Request: Add support for custom environment file names
Description
We are using the Snowplow JavaScript Tracker and the Snowtype CLI. According to the documentation, the CLI looks for a .env file to read credentials.
In our project, we use a file named .env.local for our environment variables. This requires us to either use dotenvx, or manually rename the file, or manage a separate .env file for the CLI to work, which can be cumbersome.
It would be a great quality-of-life improvement if the Snowtype CLI could accept a flag (e.g., --env-file or -e) to specify the path to a custom environment file. This would allow users to integrate the CLI more seamlessly into projects that use different naming conventions for environment files.
This change would enhance the flexibility of the tool and reduce friction for developers using a variety of project setups.
Hi @erakor - this is helpful feedback. Are you able to source the file beforehand or does the environment you are running in make this difficult? I'll pass this feedback onto the team as it seems like a reasonably straightforward thing to implement and I think improves the DX a fair bit.
@miike Thanks for the reply. Right now, we use the CLI running commands like this dotenvx run -f .env.local -- snowtype generate. So, no blocker at the moment. Just that we only use dotenvx for that situation. Would love to simplify if possible.
It's not quite as neat as a flag, but since Snowtype uses dotenv, you should be able to use the standard DOTENV_CONFIG_PATH environment variable to adjust the config path and change this:
$ DOTENV_CONFIG_PATH=.env.local npx @snowplow/snowtype generate
@jethron I finally got to trying this and I couldn't get it to work. From my investigation (with Claude's help): The DOTENV_CONFIG_PATH environment variable only works when dotenv is preloaded via node -r dotenv/config. Since Snowtype calls dotenv.config() internally (without passing a custom path), it ignores this variable and always looks for .env.
Is there another way to get your solution to work that I'm not trying?