-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Using '.env.js' extension and exporting an object sets all env variables as string #125
Comments
Interesting, I was not aware of this behavior. This is something I will look into. If you provide a number type as the value to an env var, it should remain a number and not get auto-converted to a string. |
Yes that is what I thought too. It also automatically converts booleans to strings... |
@marnixhoh can you please take a look at this issue I opened here and see what I'm doing wrong? |
This issue also effects .env-cmdrc files. I don't know if the intention is to covert all values in the file to strings, but it does. Booleans are converted to strings. Number types are converted to strings, no using 0, 1 in place of booleans. (although this is what I'm doing and parseInt() the variable in the application) This makes working with env-cmd somewhat more difficult. I feel like this was not always the case as I've used this in the past without issue. Perhaps a recent version introduced different parsing of the values? I'm experiencing this issue with v10.1.0 |
I am getting this misbehaviour too, @toddbluhm please confirm with me that you are still open for PR then I will find a way to fix this 🙏 |
This is intentional, environment variables are always strings, on all operating systems. There's some more background info on wikipedia. |
So this is an interesting question. I am not really sure where to stand on this myself. Clearly, earlier I was leaning towards interpreting the string values, and currently in I am curious if this will break a ton of stuff, or if it doesn't really matter. I know it will matter for those using the API, but I wonder if It might be better to revert the functionality to keep them always strings just for consistency with all previous versions. I am open to persuasion either way. |
Since environment variables are always strings when loaded through Line 52 in 7166412
I can only think of 1 minor risk of using booleans/numbers:
With that said, it seems like there are only 2 public repositories using Footnotes |
@k-yle you have persuaded me, I am good with keeping it strings and also not breaking backward compatibility. I can try to throw together a fix for that sometime, or you can if you like. |
Hi,
I use a config file with an '.env.js' extension and it exports an object with env variables. I noticed that these are set as strings, even though some of them are actually integers. Now I am not sure if this is expected behavior or not, but if there is some sort of workaround besides parsing the variables to integers every time they are used, that be great!
Thanks!
The text was updated successfully, but these errors were encountered: