Skip to content

Commit

Permalink
add --no-expand option to skip variable expansion (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngraef authored Mar 10, 2023
1 parent 69723ac commit 405e007
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var dotenvExpand = require('dotenv-expand').expand

function printHelp () {
console.log([
'Usage: dotenv [--help] [--debug] [-e <path>] [-v <name>=<value>] [-p <variable name>] [-c [environment]] [-- command]',
'Usage: dotenv [--help] [--debug] [-e <path>] [-v <name>=<value>] [-p <variable name>] [-c [environment]] [--no-expand] [-- command]',
' --help print help',
' --debug output the files that would be processed but don\'t actually parse them or run the `command`',
' -e <path> parses the file <path> as a `.env` file and adds the variables to the environment',
Expand All @@ -18,6 +18,7 @@ function printHelp () {
' -v <name>=<value> multiple -v flags are allowed',
' -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',
' 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 @@ -71,7 +72,10 @@ if (argv.debug) {
}

paths.forEach(function (env) {
dotenvExpand(dotenv.config({ path: path.resolve(env) }))
var parsedFile = dotenv.config({ path: path.resolve(env) })
if (argv.expand !== false) {
dotenvExpand(parsedFile)
}
})
Object.assign(process.env, parsedVariables)

Expand Down

0 comments on commit 405e007

Please sign in to comment.