@@ -915,7 +915,7 @@ std::string GetBashCompletion() {
915915
916916// Return a map containing all the options and their metadata as well
917917// as the aliases
918- void GetOptions (const FunctionCallbackInfo<Value>& args) {
918+ void GetCLIOptions (const FunctionCallbackInfo<Value>& args) {
919919 Mutex::ScopedLock lock (per_process::cli_options_mutex);
920920 Environment* env = Environment::GetCurrent (args);
921921 if (!env->has_run_bootstrapping_code ()) {
@@ -1056,13 +1056,38 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) {
10561056 args.GetReturnValue ().Set (ret);
10571057}
10581058
1059+ void GetEmbedderOptions (const FunctionCallbackInfo<Value>& args) {
1060+ Environment* env = Environment::GetCurrent (args);
1061+ if (!env->has_run_bootstrapping_code ()) {
1062+ // No code because this is an assertion.
1063+ return env->ThrowError (
1064+ " Should not query options before bootstrapping is done" );
1065+ }
1066+ Isolate* isolate = args.GetIsolate ();
1067+ Local<Context> context = env->context ();
1068+ Local<Object> ret = Object::New (isolate);
1069+
1070+ if (ret->Set (context,
1071+ FIXED_ONE_BYTE_STRING (env->isolate (), " shouldNotRegisterESMLoader" ),
1072+ Boolean::New (isolate, env->should_not_register_esm_loader ()))
1073+ .IsNothing ()) return ;
1074+
1075+ if (ret->Set (context,
1076+ FIXED_ONE_BYTE_STRING (env->isolate (), " noGlobalSearchPaths" ),
1077+ Boolean::New (isolate, env->no_global_search_paths ()))
1078+ .IsNothing ()) return ;
1079+
1080+ args.GetReturnValue ().Set (ret);
1081+ }
1082+
10591083void Initialize (Local<Object> target,
10601084 Local<Value> unused,
10611085 Local<Context> context,
10621086 void * priv) {
10631087 Environment* env = Environment::GetCurrent (context);
10641088 Isolate* isolate = env->isolate ();
1065- env->SetMethodNoSideEffect (target, " getOptions" , GetOptions);
1089+ env->SetMethodNoSideEffect (target, " getCLIOptions" , GetCLIOptions);
1090+ env->SetMethodNoSideEffect (target, " getEmbedderOptions" , GetEmbedderOptions);
10661091
10671092 Local<Object> env_settings = Object::New (isolate);
10681093 NODE_DEFINE_CONSTANT (env_settings, kAllowedInEnvironment );
@@ -1072,18 +1097,6 @@ void Initialize(Local<Object> target,
10721097 context, FIXED_ONE_BYTE_STRING (isolate, " envSettings" ), env_settings)
10731098 .Check ();
10741099
1075- target
1076- ->Set (context,
1077- FIXED_ONE_BYTE_STRING (env->isolate (), " shouldNotRegisterESMLoader" ),
1078- Boolean::New (isolate, env->should_not_register_esm_loader ()))
1079- .Check ();
1080-
1081- target
1082- ->Set (context,
1083- FIXED_ONE_BYTE_STRING (env->isolate (), " noGlobalSearchPaths" ),
1084- Boolean::New (isolate, env->no_global_search_paths ()))
1085- .Check ();
1086-
10871100 Local<Object> types = Object::New (isolate);
10881101 NODE_DEFINE_CONSTANT (types, kNoOp );
10891102 NODE_DEFINE_CONSTANT (types, kV8Option );
0 commit comments