New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process: doc-only deprecate non-string env value #18990
Closed
TimothyGu
wants to merge
1
commit into
nodejs:master
from
TimothyGu:doc-deprecate-process-env-non-string
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
Diff settings
11
src/node.cc
| @@ -2659,6 +2659,17 @@ static void EnvGetter(Local<Name> property, | |||
| static void EnvSetter(Local<Name> property, | |||
| Local<Value> value, | |||
| const PropertyCallbackInfo<Value>& info) { | |||
| Environment* env = Environment::GetCurrent(info); | |||
| if (config_pending_deprecation && env->EmitProcessEnvWarning() && | |||
| !value->IsString() && !value->IsNumber() && !value->IsBoolean()) { | |||
| if (ProcessEmitDeprecationWarning( | |||
| env, | |||
| "Assigning any value other than a string, number, or boolean value " | |||
thefourtheye
Contributor
|
|||
| "to a process.env property is deprecated. Please make sure to " | |||
| "convert the value to a string before setting process.env with it.", | |||
| "DEP00XX").IsNothing()) | |||
| return; | |||
| } | |||
| #ifdef __POSIX__ | |||
| node::Utf8Value key(info.GetIsolate(), property); | |||
| node::Utf8Value val(info.GetIsolate(), value); | |||
| @@ -0,0 +1,16 @@ | |||
| 'use strict'; | |||
| const common = require('../common'); | |||
| const assert = require('assert'); | |||
|
|
|||
| // Flags: --pending-deprecation | |||
|
|
|||
| common.expectWarning( | |||
| 'DeprecationWarning', | |||
| 'Assigning any value other than a string, number, or boolean value to a ' + | |||
| 'process.env property is deprecated. Please make sure to convert the value ' + | |||
| 'to a string before setting process.env with it.', | |||
| 'DEP00XX' | |||
| ); | |||
|
|
|||
| process.env.ABC = undefined; | |||
| assert.strictEqual(process.env.ABC, 'undefined'); | |||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Nit: I am not a native English speaker, but I believe this message can be presented better. Unfortunately, I am also not sure how to improve it.