Skip to content

Commit

Permalink
Merge branch 'jmcmullen-master'
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Tant <[email protected]>
  • Loading branch information
JulienTant committed Oct 13, 2018
2 parents a25ca09 40bbe43 commit 75f53d7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 1,11 @@
# Change Log

All notable changes to this project will be documented in this file.
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="1.3.0"></a>
## [1.3.0](https://github.com/nuxt-community/dotenv-module/compare/v1.1.1...v1.3.0) (2018-07-12)

- add `systemvars` option. Setting this to true will allow your system set variables to work.

<a name="1.2.1"></a>
## [1.2.1](https://github.com/nuxt-community/dotenv-module/compare/v1.2.0...v1.2.1) (2018-10-13)
Expand All @@ -10,7 15,7 @@ All notable changes to this project will be documented in this file.
<a name="1.2.0"></a>
## [1.2.0](https://github.com/nuxt-community/dotenv-module/compare/v1.1.1...v1.2.0) (2018-10-13)

- add `filename` options. This options allows you to use an alternative filename to replace `.env`
- add `filename` option. This options allows you to use an alternative filename to replace `.env`

<a name="1.1.1"></a>
## [1.1.1](https://github.com/nuxt-community/dotenv-module/compare/v1.1.0...v1.1.1) (2018-03-25)
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 63,18 @@ By default, the we'll be loading the `.env` file from the root of your project.
}
```

### systemvars

By default this is false and variables from your system will be ignored. Setting this to true will allow your system set variables to work.

```js
{
modules: [
['@nuxtjs/dotenv', { systemvars: true }],
]
}
```

Note that this is the path to the **folder** where the `.env` file live, not to the `.env` file itself.

The path can be absolute or relative.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
{
"name": "@nuxtjs/dotenv",
"version": "1.2.1",
"version": "1.3.0",
"description": "A nuxt.js module that loads your .env file into your context options",
"license": "MIT",
"contributors": [
Expand Down
11 changes: 10 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,8 @@ export default function DotEnvModule (moduleOptions) {
const defaultOptions = {
only: [],
path: this.options.srcDir,
filename: '.env'
filename: '.env',
systemvars: false
}

const options = Object.assign({}, defaultOptions, moduleOptions)
Expand All @@ -24,6 25,14 @@ export default function DotEnvModule (moduleOptions) {
return options.only.length === 0 || options.only.includes(key)
}

if (options.systemvars) {
Object.keys(process.env).map(key => {
if (!(key in envConfig)) {
envConfig[key] = process.env[key]
}
})
}

Object.keys(envConfig).forEach((key) => {
if (isAllowed(key)) {
this.options.env[key] = this.options.env[key] || envConfig[key]
Expand Down

0 comments on commit 75f53d7

Please sign in to comment.