env-var
env-var copied to clipboard
Add description() function
Is your feature request related to a problem? Please describe. It would be helpful to provide a description for each environment variable.
Describe the solution you'd like A .description('Specifies that and that') function which text may be used in error messages as well as enhance code readability. Moreover if a .help() function will be implemented (see separate issue) this description text may be used to generate help text.
@structinfo this certainly could be helpful. Do you think it could be used to replace the current example()
or should be used in conjunction with it?
Currently if a developer uses the example()
they get output like this on error:
env-var: "ADMIN_EMAIL" is a required variable, but it was not set. An
example of a valid value would be "[email protected]"
With description('This value is used to alert an admin...')
should this become similar to the following example?
env-var: "ADMIN_EMAIL" is a required variable, but it was not set. An
example of a valid value would be "[email protected]". This value
is used to alert an admin...
+1 to this. For example, I might let people know where to go to pick up the credentials (e.g. "Check your account settings for the API key: https://airtable.com/account").
I think example(...)
is neat. I'd add this as a separate thing.
It'd be amazing if, somehow, all of this metadata around env vars could be pulled out into a .env.template
with the examples / descriptions inlined as comments, categorised by required/optional.
Implemented in version 8. You can test it using npm install env-var@beta
. I will make an official release after some more testing.