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