@@ -124,14 +124,12 @@ using v8::MaybeLocal;
124124using v8::Message;
125125using v8::MicrotasksPolicy;
126126using v8::NewStringType;
127- using v8::None;
128127using v8::Nothing;
129128using v8::Object;
130129using v8::ObjectTemplate;
131130using v8::Script;
132131using v8::ScriptOrigin;
133132using v8::SealHandleScope;
134- using v8::SideEffectType;
135133using v8::String;
136134using v8::TracingController;
137135using v8::Undefined;
@@ -686,230 +684,6 @@ static void OnMessage(Local<Message> message, Local<Value> error) {
686684 }
687685}
688686
689- void SetupProcessObject (Environment* env,
690- const std::vector<std::string>& args,
691- const std::vector<std::string>& exec_args) {
692- Isolate* isolate = env->isolate ();
693- HandleScope scope (isolate);
694- Local<Context> context = env->context ();
695-
696- Local<Object> process = env->process_object ();
697-
698- auto title_string = FIXED_ONE_BYTE_STRING (env->isolate (), " title" );
699- CHECK (process->SetAccessor (
700- env->context (),
701- title_string,
702- ProcessTitleGetter,
703- env->is_main_thread () ? ProcessTitleSetter : nullptr ,
704- env->as_external (),
705- DEFAULT,
706- None,
707- SideEffectType::kHasNoSideEffect ).FromJust ());
708-
709- // process.version
710- READONLY_PROPERTY (process,
711- " version" ,
712- FIXED_ONE_BYTE_STRING (env->isolate (), NODE_VERSION));
713-
714- // process.versions
715- Local<Object> versions = Object::New (env->isolate ());
716- READONLY_PROPERTY (process, " versions" , versions);
717-
718- #define V (key ) \
719- if (!per_process::metadata.versions .key .empty ()) { \
720- READONLY_STRING_PROPERTY ( \
721- versions, #key, per_process::metadata.versions .key ); \
722- }
723- NODE_VERSIONS_KEYS (V)
724- #undef V
725-
726- // process.arch
727- READONLY_STRING_PROPERTY (process, " arch" , per_process::metadata.arch );
728-
729- // process.platform
730- READONLY_STRING_PROPERTY (process, " platform" , per_process::metadata.platform );
731-
732- // process.release
733- Local<Object> release = Object::New (env->isolate ());
734- READONLY_PROPERTY (process, " release" , release);
735- READONLY_STRING_PROPERTY (release, " name" , per_process::metadata.release .name );
736- #if NODE_VERSION_IS_LTS
737- READONLY_STRING_PROPERTY (release, " lts" , per_process::metadata.release .lts );
738- #endif // NODE_VERSION_IS_LTS
739-
740- #ifdef NODE_HAS_RELEASE_URLS
741- READONLY_STRING_PROPERTY (
742- release, " sourceUrl" , per_process::metadata.release .source_url );
743- READONLY_STRING_PROPERTY (
744- release, " headersUrl" , per_process::metadata.release .headers_url );
745- #ifdef _WIN32
746- READONLY_STRING_PROPERTY (
747- release, " libUrl" , per_process::metadata.release .lib_url );
748- #endif // _WIN32
749- #endif // NODE_HAS_RELEASE_URLS
750-
751- // process.argv
752- process->Set (env->context (),
753- FIXED_ONE_BYTE_STRING (env->isolate (), " argv" ),
754- ToV8Value (env->context (), args).ToLocalChecked ()).FromJust ();
755-
756- // process.execArgv
757- process->Set (env->context (),
758- FIXED_ONE_BYTE_STRING (env->isolate (), " execArgv" ),
759- ToV8Value (env->context (), exec_args)
760- .ToLocalChecked ()).FromJust ();
761-
762- // create process.env
763- process
764- ->Set (env->context (),
765- FIXED_ONE_BYTE_STRING (env->isolate (), " env" ),
766- CreateEnvVarProxy (context, isolate, env->as_external ()))
767- .FromJust ();
768-
769- READONLY_PROPERTY (process, " pid" ,
770- Integer::New (env->isolate (), uv_os_getpid ()));
771-
772- CHECK (process->SetAccessor (env->context (),
773- FIXED_ONE_BYTE_STRING (env->isolate (), " ppid" ),
774- GetParentProcessId).FromJust ());
775-
776- // -e, --eval
777- // TODO(addaleax): Remove this.
778- if (env->options ()->has_eval_string ) {
779- READONLY_PROPERTY (process,
780- " _eval" ,
781- String::NewFromUtf8 (
782- env->isolate (),
783- env->options ()->eval_string .c_str (),
784- NewStringType::kNormal ).ToLocalChecked ());
785- }
786-
787- // -p, --print
788- // TODO(addaleax): Remove this.
789- if (env->options ()->print_eval ) {
790- READONLY_PROPERTY (process, " _print_eval" , True (env->isolate ()));
791- }
792-
793- // -c, --check
794- // TODO(addaleax): Remove this.
795- if (env->options ()->syntax_check_only ) {
796- READONLY_PROPERTY (process, " _syntax_check_only" , True (env->isolate ()));
797- }
798-
799- // -i, --interactive
800- // TODO(addaleax): Remove this.
801- if (env->options ()->force_repl ) {
802- READONLY_PROPERTY (process, " _forceRepl" , True (env->isolate ()));
803- }
804-
805- // -r, --require
806- // TODO(addaleax): Remove this.
807- const std::vector<std::string>& preload_modules =
808- env->options ()->preload_modules ;
809- if (!preload_modules.empty ()) {
810- READONLY_PROPERTY (process,
811- " _preload_modules" ,
812- ToV8Value (env->context (), preload_modules)
813- .ToLocalChecked ());
814- }
815-
816- // --no-deprecation
817- if (env->options ()->no_deprecation ) {
818- READONLY_PROPERTY (process, " noDeprecation" , True (env->isolate ()));
819- }
820-
821- // --no-warnings
822- if (env->options ()->no_warnings ) {
823- READONLY_PROPERTY (process, " noProcessWarnings" , True (env->isolate ()));
824- }
825-
826- // --trace-warnings
827- if (env->options ()->trace_warnings ) {
828- READONLY_PROPERTY (process, " traceProcessWarnings" , True (env->isolate ()));
829- }
830-
831- // --throw-deprecation
832- if (env->options ()->throw_deprecation ) {
833- READONLY_PROPERTY (process, " throwDeprecation" , True (env->isolate ()));
834- }
835-
836- #ifdef NODE_NO_BROWSER_GLOBALS
837- // configure --no-browser-globals
838- READONLY_PROPERTY (process, " _noBrowserGlobals" , True (env->isolate ()));
839- #endif // NODE_NO_BROWSER_GLOBALS
840-
841- // --prof-process
842- // TODO(addaleax): Remove this.
843- if (env->options ()->prof_process ) {
844- READONLY_PROPERTY (process, " profProcess" , True (env->isolate ()));
845- }
846-
847- // --trace-deprecation
848- if (env->options ()->trace_deprecation ) {
849- READONLY_PROPERTY (process, " traceDeprecation" , True (env->isolate ()));
850- }
851-
852- // TODO(refack): move the following 4 to `node_config`
853- // --inspect-brk
854- if (env->options ()->debug_options ().wait_for_connect ()) {
855- READONLY_DONT_ENUM_PROPERTY (process,
856- " _breakFirstLine" , True (env->isolate ()));
857- }
858-
859- if (env->options ()->debug_options ().break_node_first_line ) {
860- READONLY_DONT_ENUM_PROPERTY (process,
861- " _breakNodeFirstLine" , True (env->isolate ()));
862- }
863-
864- // --inspect --debug-brk
865- if (env->options ()->debug_options ().deprecated_invocation ()) {
866- READONLY_DONT_ENUM_PROPERTY (process,
867- " _deprecatedDebugBrk" , True (env->isolate ()));
868- }
869-
870- // --debug or, --debug-brk without --inspect
871- if (env->options ()->debug_options ().invalid_invocation ()) {
872- READONLY_DONT_ENUM_PROPERTY (process,
873- " _invalidDebug" , True (env->isolate ()));
874- }
875-
876- // --security-revert flags
877- #define V (code, _, __ ) \
878- do { \
879- if (IsReverted (SECURITY_REVERT_ ## code)) { \
880- READONLY_PROPERTY (process, " REVERT_" #code, True (env->isolate ())); \
881- } \
882- } while (0 );
883- SECURITY_REVERSIONS (V)
884- #undef V
885-
886- {
887- size_t exec_path_len = 2 * PATH_MAX;
888- std::vector<char > exec_path (exec_path_len);
889- Local<String> exec_path_value;
890- if (uv_exepath (exec_path.data (), &exec_path_len) == 0 ) {
891- exec_path_value = String::NewFromUtf8 (env->isolate (),
892- exec_path.data (),
893- NewStringType::kInternalized ,
894- exec_path_len).ToLocalChecked ();
895- } else {
896- exec_path_value = String::NewFromUtf8 (env->isolate (), args[0 ].c_str (),
897- NewStringType::kInternalized ).ToLocalChecked ();
898- }
899- process->Set (env->context (),
900- FIXED_ONE_BYTE_STRING (env->isolate (), " execPath" ),
901- exec_path_value).FromJust ();
902- }
903-
904- auto debug_port_string = FIXED_ONE_BYTE_STRING (env->isolate (), " debugPort" );
905- CHECK (process->SetAccessor (env->context (),
906- debug_port_string,
907- DebugPortGetter,
908- env->is_main_thread () ? DebugPortSetter : nullptr ,
909- env->as_external ()).FromJust ());
910- }
911-
912-
913687void SignalExit (int signo) {
914688 uv_tty_reset_mode ();
915689#ifdef __FreeBSD__
0 commit comments