process: fix default env for process.execve

The `env` parameter for `process.execve` is documented to default
to `process.env`.

PR-URL: https://github.com/nodejs/node/pull/60029
Refs: https://github.com/nodejs/build/pull/4156
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Richard Lau 2025-10-01 13:47:07 +01:00 committed by GitHub
parent c08164d016
commit b8ea0e8e85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -279,7 +279,7 @@ function wrapProcessMethods(binding) {
return true;
}
function execve(execPath, args = [], env) {
function execve(execPath, args = [], env = process.env) {
emitExperimentalWarning('process.execve');
const { isMainThread } = require('internal/worker');
@ -301,7 +301,6 @@ function wrapProcessMethods(binding) {
}
const envArray = [];
if (env !== undefined) {
validateObject(env, 'env');
for (const { 0: key, 1: value } of ObjectEntries(env)) {
@ -318,7 +317,6 @@ function wrapProcessMethods(binding) {
ArrayPrototypePush(envArray, `${key}=${value}`);
}
}
}
if (execveDiagnosticChannel.hasSubscribers) {
execveDiagnosticChannel.publish({ execPath, args, env: envArray });