kHRISl33t / runtime-env-cra

Runtime environment handler for create-react-apps
MIT License
49 stars 23 forks source link

Extra spaces break variable search #13

Open AntonyF-Andreani opened 2 years ago

AntonyF-Andreani commented 2 years ago

First of all thank you very much for the library and the hard work you have done with it.

I was having trouble looking for variables in the .env because they had spaces in them by mistake.

Would it be possible to remove the extra spaces in the key specifically?

https://github.com/kHRISl33t/runtime-env-cra/blob/99b01ff8d1917e301d5217a89e2fa2234af5cf86/lib/generateConfig.js#L37

like key = key.trim()

If that's the case, I'd be happy to help.

seanblonien commented 2 years ago

Seems like a decent idea, although I wonder if it'd just be better to log an error message/warning if spaces are found in the keys.

Obviously, spaces are syntactically allowed in JavaScript objects, and yet I've never seen a scalable or open-source proiect every use keys with spaces (let alone spaces at end or beginning). So maybe a warning message + automatic trim is a better approach as it tells you the spaces are there (instead of just always trimming them without ever mentioning anything)

AntonyFagundez commented 2 years ago

Hi @seanblonien I'm so sorry for the delay, I open the PR #17 .

Should be amazing if you can check or review the PR.