-
Notifications
You must be signed in to change notification settings - Fork 122
env() removes capitalization from camel case variable names #345
Copy link
Copy link
Closed
Labels
Description
In the update to v16, it looks like the behavior of env() changed to convert all env variable names to lowercase. Here's an example to illustrate:
process.env.camelCaseArg = 'value';
process.env.lowercasearg = 'value';
const envArgs = yargs().env().argv;
console.log(`lower case: ${envArgs.lowercasearg}`);
console.log(`camel case: ${envArgs.camelCaseArg}`);
console.log(`camel case variable with lower case name: ${envArgs.camelcasearg}`);
Running this on v15.4.0 prints
lower case: value
camel case: value
camel case variable with lower case name: undefined
While in v16.0.0 and later, the same code prints
lower case: value
camel case: undefined
camel case variable with lower case name: value
Updating to v16 broke some of our code as our camel case env variables were no longer found under their original names. I'm not sure whether the change was intentional, but the API documentation for .env() still shows camel case env variable names in the argv object, which is misleading.
Reactions are currently unavailable