Skip to content

Update index.js#60

Closed
agodinhost wants to merge 1 commit intokeithmorris:developfrom
agodinhost:env-path-enhancement
Closed

Update index.js#60
agodinhost wants to merge 1 commit intokeithmorris:developfrom
agodinhost:env-path-enhancement

Conversation

@agodinhost
Copy link

Hi Keith.
I did a minor enhancement in the schema and defaults paths - now it will follow the path of the main env file.

For example:

  const DotenvExtended = new (require('dotenv-extended')) ({
    path: '../mfes-registry/.env' });

is the same as:

  const DotenvExtended = new (require('dotenv-extended')) ({
    path: '../mfes-registry/.env',
    defaults: '../mfes-registry/.env.defaults',
    schema: '../mfes-registry/.env.schema'
  });

I believe that most of the time the main env file will be stored into the same folder as the schema and defaults. It will help to reduce repetitive code.

thanks

@keithmorris
Copy link
Owner

Hi @agodinhost . Thank you for the PR. I do like the direction of this PR. However, this does present a potential issue with the documentation. The docs state that the default values for defaults option is .env.defaults and schema is .env.schema. With your change, it does not make clear that the prefix for the defaults and schema will be whatever is in the path option.

For example, someone could have .env-prod as the path option but could have .env.schema as the schema file. Without an update to the docs, they might assume that since the docs say the default is .env.schema then it would pick that up.

You could either update the docs to indicate that defaults and schema are path + '.defaults' and path + '.schema' or ES6 style `${path}.defaults` and `${path}.schema\`

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.

2 participants