toddbluhm / env-cmd

Setting environment variables from a file
https://www.npmjs.com/package/env-cmd
MIT License
1.73k stars 65 forks source link

Better errors if the JSON file is invalid #366

Open flyon opened 1 year ago

flyon commented 1 year ago

When .env-cmdrc.json for example contains an invalid trailing comma then env-cmd gives the following error:

 Failed to find .rc file at default paths: [./.env-cmdrc,./.env-cmdrc.js,./.env-cmdrc.json]

After lots of trial and error I realised it's because of a trailing comma, but env-cmd can perhaps give a more detailed error when it failed to parse a .rc file, instead of saying it cannot find any.