这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@d13r
Copy link
Contributor

@d13r d13r commented Nov 20, 2015

About five minutes after submitting issue #2 I worked out a solution! This should fix both #2 and #1.

This changes the recommended plugin usage from:

config.env.enable

To:

config.env.enable __FILE__

I'd prefer not to have to do that, but I can't work out how to get the path to the Vagrantfile. (Maybe someone with better knowledge of Vagrant internals can fix that...) In the mean time, the original method (with no parameters) will still work and still have the same effect it used to - looking in the current working directory instead of the Vagrantfile directory.

I also added three low-level methods to allow the user to call Dotenv methods directly:

config.env.load '/path/to/.anotherenv'
config.env.load! '/path/to/.env'
config.env.overload '/path/to/.env'

See the dotenv source comments for explanations of these three methods. (They don't seem to be documented anywhere else...) Note that these paths are relative to the current working directory, so File.dirname(__FILE__) may be called for here.

@gosuri
Copy link
Owner

gosuri commented Nov 28, 2015

LGTM. Thank you!

gosuri pushed a commit that referenced this pull request Nov 28, 2015
Support for loading .env in a different directory
@gosuri gosuri merged commit 7317466 into gosuri:master Nov 28, 2015
@d13r
Copy link
Contributor Author

d13r commented Dec 6, 2015

Any chance you could release a new version with this in? Thanks!

@gosuri
Copy link
Owner

gosuri commented Dec 6, 2015

Done 👍

gosuri referenced this pull request Dec 6, 2015
@d13r
Copy link
Contributor Author

d13r commented Dec 7, 2015

Cool, thanks 😄

@chenull
Copy link

chenull commented Apr 9, 2016

Hi, sorry for requesting a new feature here. From vagrant's doc, we can set/export VAGRANT_CWD so that vagrant look for Vagrantfile in that directory. but it seem's that vagrant-env plugin ignores it. I think this plugin should also look for .env from VAGRANT_CWD too. Thanks ! :)

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.

3 participants