Skip to content

Commit 8d377b1

Browse files
villelahdenvuoCopilotentropitor
authored
Add quiet flag to suppress dotenv debug output by default (#129)
* Add quiet flag to suppress dotenv debug output by default (#2) Co-authored-by: villelahdenvuo <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> * chore: update help string Co-authored-by: Jens Claes <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: villelahdenvuo <[email protected]> Co-authored-by: Jens Claes <[email protected]>
1 parent 0da11b9 commit 8d377b1

File tree

5 files changed

+3724
-270
lines changed

5 files changed

+3724
-270
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
.env

cli.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ const dotenvExpand = require('dotenv-expand').expand
99

1010
function printHelp () {
1111
console.log([
12-
'Usage: dotenv [--help] [--debug] [-e <path>] [-v <name>=<value>] [-p <variable name>] [-c [environment]] [--no-expand] [-- command]',
12+
'Usage: dotenv [--help] [--debug] [--quiet=false] [-e <path>] [-v <name>=<value>] [-p <variable name>] [-c [environment]] [--no-expand] [-- command]',
1313
' --help print help',
1414
' --debug output the files that would be processed but don\'t actually parse them or run the `command`',
15+
' --quiet, -q suppress debug output from dotenv (default: true)',
1516
' -e <path> parses the file <path> as a `.env` file and adds the variables to the environment',
1617
' -e <path> multiple -e flags are allowed',
1718
' -v <name>=<value> put variable <name> into environment using value <value>',
@@ -31,6 +32,9 @@ if (argv.help) {
3132

3233
const override = argv.o || argv.override
3334

35+
// Handle quiet flag - default is true (quiet), can be disabled with --quiet=false or -q=false
36+
const isQuiet = !(argv.quiet === false || argv.q === false || argv.quiet === 'false' || argv.q === 'false')
37+
3438
if (argv.c && override) {
3539
console.error('Invalid arguments. Cascading env variables conflicts with overrides.')
3640
process.exit(1)
@@ -81,14 +85,14 @@ if (argv.debug) {
8185
}
8286

8387
paths.forEach(function (env) {
84-
dotenv.config({ path: path.resolve(env), override })
88+
dotenv.config({ path: path.resolve(env), override, quiet: isQuiet })
8589
})
8690

8791
// Expand when all path configs are loaded
8892
if (argv.expand !== false) {
8993
dotenvExpand({
9094
parsed: process.env
91-
});
95+
})
9296
}
9397
Object.assign(process.env, parsedVariables)
9498

0 commit comments

Comments
 (0)