Undocumented ```delete process.env.DEBUG``` when variable is empty

Abierto
#845 3 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Documentación
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, node.js

Línea de trabajo

Start with the README and the behavior described when the debug package is required before dotenv loads. Document that an empty DEBUG environment variable may be removed, and include the proposed DEBUG=, workaround if appropriate. Done means the README clearly explains this behavior and its effect on later process.env.DEBUG checks.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug change-major

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.

Lenguaje dominante
JavaScript
Estrellas
11.5k
Forks
992
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de debug-js/debug

Todos los issues de debug-js/debug

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.