hughsk / envify

:wrench: Selectively replace Node-style environment variables with plain strings.
901 stars 57 forks source link

Set environment variables from the file #37

Closed vadimdemedes closed 8 years ago

vadimdemedes commented 8 years ago

Would be lovely, if envify supported setting env variables from the file (e.g. .env):

$ envify -f .env

.env:

VAR1=abc
VAR2=cba

Real use case: storing API keys for some services (e.g. MapBox) in .env file and wanting to replace process.env.API_KEY in code with those values.

vadimdemedes commented 8 years ago

Happy to submit a PR, if you also want this feature.

yoshuawuyts commented 8 years ago

I'm generally hesitant to endorse adding features to this package, but I feel this might be a useful addition to the cli. I'd be happy to review a PR on this.

vadimdemedes commented 8 years ago

It wouldn't be very useful if this feature remained only in CLI and not in the lib/custom.js, as (I assume) most people use envify as a browserify transformer (browserify -t envify).

yoshuawuyts commented 8 years ago

Oh yeah, that's what I meant haha. As long as it's an action that happens on the command line it's fine. Just don't think reading files should be part of the js api as that would mangle concerns.

hughsk commented 8 years ago

This functionality would be better implemented in a separate package, envify already has too many features as-is. See also: envlocalify.

vadimdemedes commented 8 years ago

No worries ;)

@hughsk Thanks for envlocalify reference.