Skip to content
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

Merged
merged 4 commits into from
Mar 20, 2017
Merged

Conversation

zhongzhi107
Copy link
Contributor

@zhongzhi107 zhongzhi107 commented Mar 7, 2017

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

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'})
Copy link
Owner

@benoror benoror left a 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];
}
});
Copy link
Owner

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?

Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants