-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support more dotenv options #65
Conversation
Options Path Default: .env You can specify a custom path if your file containing environment variables is named or located differently. require('dotenv').config({path: '/custom/path/to/your/env/vars'}) Encoding Default: utf8 You may specify the encoding of your file containing environment variables using this option. require('dotenv').config({encoding: 'base64'})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @zhongzhi107 thanks for your contrib, and sorry for the late response. I proposed some simple changes, other than that LGTM :)
lib/exec.js
Outdated
if (key in program) { | ||
dotenvConfig[key] = program[key]; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you simplify this by using object-assign (as we're already using it here) 😄
Something like:
var dotenvConfig = objectAssign({ silent: true }, program);
Or more specific:
var dotenvConfig = objectAssign({ silent: true }, {
encoding: program.encoding,
path: program.path
});
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
I'll do it right away.
README.md
Outdated
|
||
``` | ||
bnr watch-client -s | ||
``` | ||
|
||
And you can use `-p` or verbose `--path` specify a custom path of dotenv file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you can use -p
or verbose --path
to specify a custom path of dotenv file
README.md
Outdated
bnr start-dev --path=/custom/path/to/your/env/vars | ||
``` | ||
|
||
Also use `-e` or verbose `--encoding` specify the encoding of dotenv file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use -e
or verbose --encoding
to specify the encoding of dotenv file
Sometimes, I want to control dotenv more precisely, so I added some options to dotenv. Options are as follows:
Options
Path
Default: .env
You can specify a custom path if your file containing environment
variables is named or located differently.
better-npm-run your-task --path=/custom/path/to/your/env/vars
or use short name
better-npm-run your-task -p /custom/path/to/your/env/vars
Encoding
Default: utf8
You may specify the encoding of your file containing environment
variables using this option.
better-npm-run your-task -e base64