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

オープン
#845 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, node.js
領域
documentation

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
11.5k
フォーク
992
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

debug-js/debug のほかの issue

debug-js/debug の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。