Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.env
10 changes: 7 additions & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const dotenvExpand = require('dotenv-expand').expand

function printHelp () {
console.log([
'Usage: dotenv [--help] [--debug] [-e <path>] [-v <name>=<value>] [-p <variable name>] [-c [environment]] [--no-expand] [-- command]',
'Usage: dotenv [--help] [--debug] [--quiet=false] [-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`',
' --quiet, -q suppress debug output from dotenv (default: true)',
' -e <path> parses the file <path> as a `.env` file and adds the variables to the environment',
' -e <path> multiple -e flags are allowed',
' -v <name>=<value> put variable <name> into environment using value <value>',
Expand All @@ -31,6 +32,9 @@ if (argv.help) {

const override = argv.o || argv.override

// Handle quiet flag - default is true (quiet), can be disabled with --quiet=false or -q=false
const isQuiet = !(argv.quiet === false || argv.q === false || argv.quiet === 'false' || argv.q === 'false')

if (argv.c && override) {
console.error('Invalid arguments. Cascading env variables conflicts with overrides.')
process.exit(1)
Expand Down Expand Up @@ -81,14 +85,14 @@ if (argv.debug) {
}

paths.forEach(function (env) {
dotenv.config({ path: path.resolve(env), override })
dotenv.config({ path: path.resolve(env), override, quiet: isQuiet })
})

// Expand when all path configs are loaded
if (argv.expand !== false) {
dotenvExpand({
parsed: process.env
});
})
}
Object.assign(process.env, parsedVariables)

Expand Down
Loading