diff --git a/src/env.h b/src/env.h index acbdd013285d6c..67e3d7f380a695 100644 --- a/src/env.h +++ b/src/env.h @@ -62,23 +62,15 @@ class Worker; namespace loader { class ModuleWrap; -struct Exists { - enum Bool { Yes, No }; -}; - -struct IsValid { - enum Bool { Yes, No }; -}; - -struct HasMain { - enum Bool { Yes, No }; -}; - struct PackageConfig { - const Exists::Bool exists; - const IsValid::Bool is_valid; - const HasMain::Bool has_main; - const std::string main; + enum class Exists { Yes, No }; + enum class IsValid { Yes, No }; + enum class HasMain { Yes, No }; + + Exists exists; + IsValid is_valid; + HasMain has_main; + std::string main; }; } // namespace loader @@ -670,7 +662,8 @@ class Environment { std::unordered_multimap module_map; - std::unordered_map package_json_cache; + std::unordered_map + package_json_cache; inline double* heap_statistics_buffer() const; inline void set_heap_statistics_buffer(double* pointer); diff --git a/src/module_wrap.cc b/src/module_wrap.cc index ab1950311ad631..63e886ab0d7ac0 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -488,8 +488,12 @@ Maybe CheckFile(const std::string& path, return Just(fd); } +using Exists = PackageConfig::Exists; +using IsValid = PackageConfig::IsValid; +using HasMain = PackageConfig::HasMain; + const PackageConfig& GetPackageConfig(Environment* env, - const std::string path) { + const std::string& path) { auto existing = env->package_json_cache.find(path); if (existing != env->package_json_cache.end()) { return existing->second; @@ -530,7 +534,7 @@ const PackageConfig& GetPackageConfig(Environment* env, } Local pkg_main; - HasMain::Bool has_main = HasMain::No; + HasMain has_main = HasMain::No; std::string main_std; if (pkg_json->Get(env->context(), env->main_string()).ToLocal(&pkg_main)) { has_main = HasMain::Yes;