| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 30858ec commit 49cfb9d
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,34 +78,9 @@ static void GetParentProcessId(Local<Name> property, | |||
| 78 | 78 | info.GetReturnValue().Set(uv_os_getppid()); | |
| 79 | 79 | } | |
| 80 | 80 | ||
| 81 | - MaybeLocal<Object> CreateProcessObject(Realm* realm) { | ||
| 82 | - Isolate* isolate = realm->isolate(); | ||
| 83 | - EscapableHandleScope scope(isolate); | ||
| 84 | - Local<Context> context = realm->context(); | ||
| 85 | - | ||
| 86 | - Local<FunctionTemplate> process_template = FunctionTemplate::New(isolate); | ||
| 87 | - process_template->SetClassName(realm->env()->process_string()); | ||
| 88 | - Local<Function> process_ctor; | ||
| 89 | - Local<Object> process; | ||
| 90 | - if (!process_template->GetFunction(context).ToLocal(&process_ctor) || | ||
| 91 | - !process_ctor->NewInstance(context).ToLocal(&process)) { | ||
| 92 | - return MaybeLocal<Object>(); | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - // process[exit_info_private_symbol] | ||
| 96 | - if (process | ||
| 97 | - ->SetPrivate(context, | ||
| 98 | - realm->env()->exit_info_private_symbol(), | ||
| 99 | - realm->env()->exit_info().GetJSArray()) | ||
| 100 | - .IsNothing()) { | ||
| 101 | - return {}; | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - // process.version | ||
| 105 | - READONLY_PROPERTY( | ||
| 106 | - process, "version", FIXED_ONE_BYTE_STRING(isolate, NODE_VERSION)); | ||
| 81 | + static void SetVersions(Isolate* isolate, Local<Object> versions) { | ||
| 82 | + Local<Context> context = isolate->GetCurrentContext(); | ||
| 107 | 83 | ||
| 108 | - Local<Object> versions = Object::New(isolate); | ||
| 109 | 84 | // Node.js version is always on the top | |
| 110 | 85 | READONLY_STRING_PROPERTY( | |
| 111 | 86 | versions, "node", per_process::metadata.versions.node); | |
@@ -138,8 +113,38 @@ MaybeLocal<Object> CreateProcessObject(Realm* realm) { | |||
| 138 | 113 | v8::ReadOnly) | |
| 139 | 114 | .Check(); | |
| 140 | 115 | } | |
| 116 | + } | ||
| 117 | + | ||
| 118 | + MaybeLocal<Object> CreateProcessObject(Realm* realm) { | ||
| 119 | + Isolate* isolate = realm->isolate(); | ||
| 120 | + EscapableHandleScope scope(isolate); | ||
| 121 | + Local<Context> context = realm->context(); | ||
| 122 | + | ||
| 123 | + Local<FunctionTemplate> process_template = FunctionTemplate::New(isolate); | ||
| 124 | + process_template->SetClassName(realm->env()->process_string()); | ||
| 125 | + Local<Function> process_ctor; | ||
| 126 | + Local<Object> process; | ||
| 127 | + if (!process_template->GetFunction(context).ToLocal(&process_ctor) || | ||
| 128 | + !process_ctor->NewInstance(context).ToLocal(&process)) { | ||
| 129 | + return MaybeLocal<Object>(); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + // process[exit_info_private_symbol] | ||
| 133 | + if (process | ||
| 134 | + ->SetPrivate(context, | ||
| 135 | + realm->env()->exit_info_private_symbol(), | ||
| 136 | + realm->env()->exit_info().GetJSArray()) | ||
| 137 | + .IsNothing()) { | ||
| 138 | + return {}; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + // process.version | ||
| 142 | + READONLY_PROPERTY( | ||
| 143 | + process, "version", FIXED_ONE_BYTE_STRING(isolate, NODE_VERSION)); | ||
| 141 | 144 | ||
| 142 | 145 | // process.versions | |
| 146 | + Local<Object> versions = Object::New(isolate); | ||
| 147 | + SetVersions(isolate, versions); | ||
| 143 | 148 | READONLY_PROPERTY(process, "versions", versions); | |
| 144 | 149 | ||
| 145 | 150 | // process.arch | |
@@ -241,6 +246,11 @@ void PatchProcessObject(const FunctionCallbackInfo<Value>& args) { | |||
| 241 | 246 | env->owns_process_state() ? DebugPortSetter : nullptr, | |
| 242 | 247 | Local<Value>()) | |
| 243 | 248 | .FromJust()); | |
| 249 | + | ||
| 250 | + // process.versions | ||
| 251 | + Local<Object> versions = Object::New(isolate); | ||
| 252 | + SetVersions(isolate, versions); | ||
| 253 | + READONLY_PROPERTY(process, "versions", versions); | ||
| 244 | 254 | } | |
| 245 | 255 | ||
| 246 | 256 | void RegisterProcessExternalReferences(ExternalReferenceRegistry* registry) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments