process: check env->EmitProcessEnvWarning() last
Calling env->EmitProcessEnvWarning() prevents additional warnings from being set it should therefore be called only if a warning will emit. PR-URL: https://github.com/nodejs/node/pull/25575 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
f698386c7e
commit
0b50972e6c
@ -72,8 +72,12 @@ static void EnvSetter(Local<Name> property,
|
|||||||
Local<Value> value,
|
Local<Value> value,
|
||||||
const PropertyCallbackInfo<Value>& info) {
|
const PropertyCallbackInfo<Value>& info) {
|
||||||
Environment* env = Environment::GetCurrent(info);
|
Environment* env = Environment::GetCurrent(info);
|
||||||
if (env->options()->pending_deprecation && env->EmitProcessEnvWarning() &&
|
// calling env->EmitProcessEnvWarning() sets a variable indicating that
|
||||||
!value->IsString() && !value->IsNumber() && !value->IsBoolean()) {
|
// warnings have been emitted. It should be called last after other
|
||||||
|
// conditions leading to a warning have been met.
|
||||||
|
if (env->options()->pending_deprecation && !value->IsString() &&
|
||||||
|
!value->IsNumber() && !value->IsBoolean() &&
|
||||||
|
env->EmitProcessEnvWarning()) {
|
||||||
if (ProcessEmitDeprecationWarning(
|
if (ProcessEmitDeprecationWarning(
|
||||||
env,
|
env,
|
||||||
"Assigning any value other than a string, number, or boolean to a "
|
"Assigning any value other than a string, number, or boolean to a "
|
||||||
|
@ -12,5 +12,9 @@ common.expectWarning(
|
|||||||
'DEP0104'
|
'DEP0104'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Make sure setting a valid environment variable doesn't
|
||||||
|
// result in warning being suppressed, see:
|
||||||
|
// https://github.com/nodejs/node/pull/25157
|
||||||
|
process.env.FOO = 'apple';
|
||||||
process.env.ABC = undefined;
|
process.env.ABC = undefined;
|
||||||
assert.strictEqual(process.env.ABC, 'undefined');
|
assert.strictEqual(process.env.ABC, 'undefined');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user