env-cmd
env-cmd copied to clipboard
Using '.env.js' extension and exporting an object sets all env variables as string
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!
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... Let me know if there is anything I can do to help
@marnixhoh can you please take a look at this issue I opened here and see what I'm doing wrong? I cant seem to use *.js for env files
https://github.com/toddbluhm/env-cmd/issues/208
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 :pray: