You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a weird one. When passing a value to an argument via the command line, while also defining a fallback on process.env, [object Object] is returned instead of the correct value.
I took these steps to reproduce the issue:
In a new directory do npm install args
Create a file fail.js with these contents:
constargs=require('args');args.option(['p','port'],'The port to run on',process.env.PORT||3000);constconfig=args.parse(process.argv);console.log(`Your port is: ${config.port}`);
Run the following tests on the CLI and observe the weird results:
$ node fail.js
Your port is: 3000 # all good
$ node fail.js -p 1000
Your port is: 1000 # all good
$ PORT=1000 node fail.js
Your port is: 1000 # all good
$ PORT=1000 node fail.js -p 1001
Your port is: [object Object] # failure
Note if I take out process.env in that script and instead specify a single default value of 3000 with no fallback everything works as expected.
Happy to look into resolving the issue if you don't have time to, as it's currently causing bugs in the master branch of slackin here: rauchg/slackin#206
The text was updated successfully, but these errors were encountered:
This is a weird one. When passing a value to an argument via the command line, while also defining a fallback on
process.env
,[object Object]
is returned instead of the correct value.I took these steps to reproduce the issue:
npm install args
fail.js
with these contents:Note if I take out
process.env
in that script and instead specify a single default value of3000
with no fallback everything works as expected.Happy to look into resolving the issue if you don't have time to, as it's currently causing bugs in the
master
branch of slackin here: rauchg/slackin#206The text was updated successfully, but these errors were encountered: