Skip to content

Commit

Permalink
feat: expose 'override' option from 'dotenv'
Browse files Browse the repository at this point in the history
  • Loading branch information
jfairley committed Mar 17, 2023
1 parent 61fb060 commit 78315a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ Therefore, `dotenv-cli` will start a child process `bash -c 'echo "$SAY_HI"'` wi

You can add the `--debug` flag to output the `.env` files that would be processed and exit.

### Override

Override any environment variables that have already been set on your machine with values from your .env file.

```bash
dotenv -c test -o -- jest
```

## License

[MIT](https://en.wikipedia.org/wiki/MIT_License)
3 changes: 2 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function printHelp () {
' -p <variable> print value of <variable> to the console. If you specify this, you do not have to specify a `command`',
' -c [environment] support cascading env variables from `.env`, `.env.<environment>`, `.env.local`, `.env.<environment>.local` files',
' --no-expand skip variable expansion',
' -o, --override override system variables',
' command `command` is the actual command you want to run. Best practice is to precede this command with ` -- `. Everything after `--` is considered to be your command. So any flags will not be parsed by this tool but be passed to your command. If you do not do it, this tool will strip those flags'
].join('\n'))
}
Expand Down Expand Up @@ -72,7 +73,7 @@ if (argv.debug) {
}

paths.forEach(function (env) {
var parsedFile = dotenv.config({ path: path.resolve(env) })
var parsedFile = dotenv.config({ path: path.resolve(env), override: argv.o || argv.override })
if (argv.expand !== false) {
dotenvExpand(parsedFile)
}
Expand Down

0 comments on commit 78315a4

Please sign in to comment.