Handling config passed via CLI
tusharmath opened this issue · 1 comments
Consider a use case where —
default.json
{
"watch": false,
"port": 9000
}
Command line
node server.js --port=3000
node-config-ts
will automatically override the port value of 9000
with 3000
. This is a great feature to have but sometimes it can cause conflicts when the command line argument isn't actually intended to override the config.
For example while running tests for the same server.js as follows —
mocha test/server.test.js --watch
The watch
passed is intended to be used by mocha
and not by server.js
. But in this case
the config object will automatically contain watch
property which will be set to true. This can change the behaviour of the program drastically.
Also, specifically boolean
and number
values are not converted and their typeof
shows them as string
s while the TypeScript definition is boolean
or number
.