Description
I would just like to point out to the fact that when required, debug package will remove the DEBUG env variable if empty.
I think it would be nice if this is mentioned in the readme, as I feel its a non obvious behavior.
The use case I noticed this on is:
command:
npm install dotenv
DEBUG= npx mocha --require bootstrap.js
files:
.env
DEBUG=*
bootstrap.js
console.log(process.env.DEBUG);
require('dotenv').config();
console.log(process.env.DEBUG);
output:
undefined // we lost the DEBUG env already
'*' // we get .env file DEBUG setting, but we should have gotten '', because dotenv never overrides set env variables (* actually after version 4 I believe)
problem:
mocha uses the debug package which deletes the env variable. Our user code in bootstrap.js then has no way of knowing if DEBUG was set to an empty string or not supplied. Therefore we get full debug info instead of none.
More general - any code used before using process.env.DEBUG might delete the env variable through just depending on the debug package.
solution
I propose we either not delete the DEBUG variable or have a section in documentation to explain and suggest maybe using DEBUG=,
to disable debug logging.