diff --git a/src/node_dotenv.cc b/src/node_dotenv.cc index 27f9c30c55714a..af7433d2a08369 100644 --- a/src/node_dotenv.cc +++ b/src/node_dotenv.cc @@ -42,10 +42,6 @@ std::vector Dotenv::GetPathFromArgs( } void Dotenv::SetEnvironment(node::Environment* env) { - if (store_.empty()) { - return; - } - auto isolate = env->isolate(); for (const auto& entry : store_) { @@ -67,7 +63,7 @@ void Dotenv::SetEnvironment(node::Environment* env) { } } -Local Dotenv::ToObject(Environment* env) { +Local Dotenv::ToObject(Environment* env) const { Local result = Object::New(env->isolate()); for (const auto& entry : store_) { @@ -263,7 +259,7 @@ Dotenv::ParseResult Dotenv::ParsePath(const std::string_view path) { return ParseResult::Valid; } -void Dotenv::AssignNodeOptionsIfAvailable(std::string* node_options) { +void Dotenv::AssignNodeOptionsIfAvailable(std::string* node_options) const { auto match = store_.find("NODE_OPTIONS"); if (match != store_.end()) { diff --git a/src/node_dotenv.h b/src/node_dotenv.h index 33ed63a9bef33f..ef9ee54a9e75ce 100644 --- a/src/node_dotenv.h +++ b/src/node_dotenv.h @@ -15,17 +15,17 @@ class Dotenv { enum ParseResult { Valid, FileError, InvalidContent }; Dotenv() = default; - Dotenv(const Dotenv& d) = default; + Dotenv(const Dotenv& d) = delete; Dotenv(Dotenv&& d) noexcept = default; Dotenv& operator=(Dotenv&& d) noexcept = default; - Dotenv& operator=(const Dotenv& d) = default; + Dotenv& operator=(const Dotenv& d) = delete; ~Dotenv() = default; void ParseContent(const std::string_view content); ParseResult ParsePath(const std::string_view path); - void AssignNodeOptionsIfAvailable(std::string* node_options); + void AssignNodeOptionsIfAvailable(std::string* node_options) const; void SetEnvironment(Environment* env); - v8::Local ToObject(Environment* env); + v8::Local ToObject(Environment* env) const; static std::vector GetPathFromArgs( const std::vector& args);