-
-
Notifications
You must be signed in to change notification settings - Fork 360
Allow configuration option for dotenv path. #517
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
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
It's a bit sad it's gone stale but I suggest this to be looked into as well. Maybe there is a different approach to why I need that: I work with docker and therefore have my .env file in a subfolder for the server. |
I'm open to PRs though, haven't looked into this yet at all, so can't tell if the library we use allows changing the path to the file. But I hardly guess it does. |
Let me have a look. I am quite new to contributing on github but happy to check. The library you are using I guess is dotenv for loading the .env file variables into the process.env object. The good news is that dotenv allows for a path definition: https://github.com/motdotla/dotenv#options What I guess I have to figure out is how we can use command line parameters as an input to define this config variable (or to default to root if none is passed in). Thanks for offering to contribute! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
It's a shame this was closed as stale, I could use this feature at work right now. |
Well go ahead and open a PR. |
I would have already done so if I had the time to do it, just expressing my support for the feature. In the meantime, and perhaps helpful for others reading this issue, I am just writing a simple require('dotenv').config({path: path.join(__dirname, '../.env.test')}); And then (assuming everything works as expected) running migrations following this example repo: https://github.com/db-migrate/api-examples/blob/master/index.js |
A "could we reopen this, would be quite useful for me" would have been way more appropriate, than "iit's a shame". |
In a monorepo environment with lerna the migration script will not work until this problem is fixed! |
Please someone document this. |
@kiliw Feel free, don't talk, do -> https://github.com/db-migrate/english-docs |
@wzrdtales Thanks for your response. I tried the command from #613 (comment) but the custom path is not working. |
dotenv
only works if your.env
file is in the root folder.It would be nice to have an option to have that file elsewhere. eg:
./node_modules/db-migrate/bin/db-migrate --dotenv ./config/.env ...
The text was updated successfully, but these errors were encountered: