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

Add check for env variables presence #45

Merged
merged 3 commits into from
Dec 6, 2017
Merged

Add check for env variables presence #45

merged 3 commits into from
Dec 6, 2017

Conversation

ondrejsevcik
Copy link
Contributor

Should solve #44

Copy link
Collaborator

@SergeAstapov SergeAstapov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we print warning notice even if failOnMissingKey is set to false? This can be helpful and even backward compatible - notice by default with opt-in for failing build.

index.js Outdated
let loadedConfig = dotenv.parse(fs.readFileSync(options.path));
let allowedKeys = options.clientAllowedKeys || [];
let loadedConfig = dotenv.config({ path: options.path });
if (loadedConfig.error && options.failOnMissingKey) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ondrejsevcik these two errors does not seem to be related - loadedConfig.error would mean that .env file was not found or has syntax error. What did you intend to achieve with this change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also confused, can you drop a comment in the source if it's meaningful?

index.js Outdated
}, {});
if (options.failOnMissingKey) {
allowedKeys.map(key => {
if (!loadedConfig.parsed[key]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ondrejsevcik this can break your build if key value is false but I believe there are use cases when false is a valid key. Should we compare with undefined?

@ondrejsevcik
Copy link
Contributor Author

thanks for the review, hopefully it's much clearer now. And I've also incorporated your suggestions.

index.js Outdated

let allowedKeys = options.clientAllowedKeys || [];

allowedKeys.map(key => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ondrejsevcik minor - could you please use forEach here as it seems more appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

@SergeAstapov
Copy link
Collaborator

LGTM!
@jasonmit any suggestions?

Thank you @ondrejsevcik for working on this!

@jasonmit jasonmit merged commit a3c1b28 into fivetanley:master Dec 6, 2017
@jasonmit
Copy link
Collaborator

jasonmit commented Dec 6, 2017

LGTM, thanks!

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

3 participants