From d41ed44f49fca3662e5b58c7414f85be30c9056f Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 11 Jul 2024 20:48:13 -0400 Subject: [PATCH] src: move `loadEnvFile` toNamespacedPath call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/53658 Reviewed-By: Vinícius Lourenço Claro Cardoso Reviewed-By: James M Snell --- lib/internal/process/per_thread.js | 3 +-- src/node_process_methods.cc | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 62d6ba2e94ad1d..6fdf5dafcedafc 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -47,7 +47,6 @@ const { validateObject, } = require('internal/validators'); const { getValidatedPath } = require('internal/fs/utils'); -const { toNamespacedPath } = require('path'); const constants = internalBinding('constants').os.signals; const kInternal = Symbol('internal properties'); @@ -255,7 +254,7 @@ function wrapProcessMethods(binding) { function loadEnvFile(path = undefined) { // Provide optional value so that `loadEnvFile.length` returns 0 if (path != null) { path = getValidatedPath(path); - _loadEnvFile(toNamespacedPath(path)); + _loadEnvFile(path); } else { _loadEnvFile(); } diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index 21d289dc77fb6b..d39e49e355ef2e 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -9,6 +9,7 @@ #include "node_external_reference.h" #include "node_internals.h" #include "node_process-inl.h" +#include "path.h" #include "util-inl.h" #include "uv.h" #include "v8-fast-api-calls.h" @@ -474,7 +475,8 @@ static void LoadEnvFile(const v8::FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); std::string path = ".env"; if (args.Length() == 1) { - Utf8Value path_value(args.GetIsolate(), args[0]); + BufferValue path_value(args.GetIsolate(), args[0]); + ToNamespacedPath(env, &path_value); path = path_value.ToString(); }