@@ -93,39 +93,46 @@ class ProcessWrap : public HandleWrap {
9393 static void ParseStdioOptions (Environment* env,
9494 Local<Object> js_options,
9595 uv_process_options_t * options) {
96+ Local<Context> context = env->context ();
9697 Local<String> stdio_key = env->stdio_string ();
97- Local<Array> stdios = js_options->Get (stdio_key).As <Array>();
98+ Local<Array> stdios =
99+ js_options->Get (context, stdio_key).ToLocalChecked ().As <Array>();
98100
99101 uint32_t len = stdios->Length ();
100102 options->stdio = new uv_stdio_container_t [len];
101103 options->stdio_count = len;
102104
103105 for (uint32_t i = 0 ; i < len; i++) {
104- Local<Object> stdio = stdios->Get (i).As <Object>();
105- Local<Value> type = stdio->Get (env->type_string ());
106+ Local<Object> stdio =
107+ stdios->Get (context, i).ToLocalChecked ().As <Object>();
108+ Local<Value> type =
109+ stdio->Get (context, env->type_string ()).ToLocalChecked ();
106110
107111 if (type->Equals (env->ignore_string ())) {
108112 options->stdio [i].flags = UV_IGNORE;
109113 } else if (type->Equals (env->pipe_string ())) {
110114 options->stdio [i].flags = static_cast <uv_stdio_flags>(
111115 UV_CREATE_PIPE | UV_READABLE_PIPE | UV_WRITABLE_PIPE);
112116 Local<String> handle_key = env->handle_string ();
113- Local<Object> handle = stdio->Get (handle_key).As <Object>();
117+ Local<Object> handle =
118+ stdio->Get (context, handle_key).ToLocalChecked ().As <Object>();
114119 CHECK (!handle.IsEmpty ());
115120 options->stdio [i].data .stream =
116121 reinterpret_cast <uv_stream_t *>(
117122 Unwrap<PipeWrap>(handle)->UVHandle ());
118123 } else if (type->Equals (env->wrap_string ())) {
119124 Local<String> handle_key = env->handle_string ();
120- Local<Object> handle = stdio->Get (handle_key).As <Object>();
125+ Local<Object> handle =
126+ stdio->Get (context, handle_key).ToLocalChecked ().As <Object>();
121127 uv_stream_t * stream = HandleToStream (env, handle);
122128 CHECK_NE (stream, nullptr );
123129
124130 options->stdio [i].flags = UV_INHERIT_STREAM;
125131 options->stdio [i].data .stream = stream;
126132 } else {
127133 Local<String> fd_key = env->fd_string ();
128- int fd = static_cast <int >(stdio->Get (fd_key)->IntegerValue ());
134+ int fd = static_cast <int >(
135+ stdio->Get (context, fd_key).ToLocalChecked ()->IntegerValue ());
129136 options->stdio [i].flags = UV_INHERIT_FD;
130137 options->stdio [i].data .fd = fd;
131138 }
@@ -134,7 +141,7 @@ class ProcessWrap : public HandleWrap {
134141
135142 static void Spawn (const FunctionCallbackInfo<Value>& args) {
136143 Environment* env = Environment::GetCurrent (args);
137-
144+ Local<Context> context = env-> context ();
138145 ProcessWrap* wrap;
139146 ASSIGN_OR_RETURN_UNWRAP (&wrap, args.Holder ());
140147
@@ -146,62 +153,70 @@ class ProcessWrap : public HandleWrap {
146153 options.exit_cb = OnExit;
147154
148155 // options.uid
149- Local<Value> uid_v = js_options->Get (env->uid_string ());
156+ Local<Value> uid_v =
157+ js_options->Get (context, env->uid_string ()).ToLocalChecked ();
150158 if (!uid_v->IsUndefined () && !uid_v->IsNull ()) {
151159 CHECK (uid_v->IsInt32 ());
152- const int32_t uid = uid_v->Int32Value (env-> context () ).FromJust ();
160+ const int32_t uid = uid_v->Int32Value (context).FromJust ();
153161 options.flags |= UV_PROCESS_SETUID;
154162 options.uid = static_cast <uv_uid_t >(uid);
155163 }
156164
157165 // options.gid
158- Local<Value> gid_v = js_options->Get (env->gid_string ());
166+ Local<Value> gid_v =
167+ js_options->Get (context, env->gid_string ()).ToLocalChecked ();
159168 if (!gid_v->IsUndefined () && !gid_v->IsNull ()) {
160169 CHECK (gid_v->IsInt32 ());
161- const int32_t gid = gid_v->Int32Value (env-> context () ).FromJust ();
170+ const int32_t gid = gid_v->Int32Value (context).FromJust ();
162171 options.flags |= UV_PROCESS_SETGID;
163172 options.gid = static_cast <uv_gid_t >(gid);
164173 }
165174
166175 // TODO(bnoordhuis) is this possible to do without mallocing ?
167176
168177 // options.file
169- Local<Value> file_v = js_options->Get (env->file_string ());
178+ Local<Value> file_v =
179+ js_options->Get (context, env->file_string ()).ToLocalChecked ();
170180 CHECK (file_v->IsString ());
171181 node::Utf8Value file (env->isolate (), file_v);
172182 options.file = *file;
173183
174184 // options.args
175- Local<Value> argv_v = js_options->Get (env->args_string ());
185+ Local<Value> argv_v =
186+ js_options->Get (context, env->args_string ()).ToLocalChecked ();
176187 if (!argv_v.IsEmpty () && argv_v->IsArray ()) {
177188 Local<Array> js_argv = Local<Array>::Cast (argv_v);
178189 int argc = js_argv->Length ();
179190 // Heap allocate to detect errors. +1 is for nullptr.
180191 options.args = new char *[argc + 1 ];
181192 for (int i = 0 ; i < argc; i++) {
182- node::Utf8Value arg (env->isolate (), js_argv->Get (i));
193+ node::Utf8Value arg (env->isolate (),
194+ js_argv->Get (context, i).ToLocalChecked ());
183195 options.args [i] = strdup (*arg);
184196 CHECK_NE (options.args [i], nullptr );
185197 }
186198 options.args [argc] = nullptr ;
187199 }
188200
189201 // options.cwd
190- Local<Value> cwd_v = js_options->Get (env->cwd_string ());
202+ Local<Value> cwd_v =
203+ js_options->Get (context, env->cwd_string ()).ToLocalChecked ();
191204 node::Utf8Value cwd (env->isolate (),
192205 cwd_v->IsString () ? cwd_v : Local<Value>());
193206 if (cwd.length () > 0 ) {
194207 options.cwd = *cwd;
195208 }
196209
197210 // options.env
198- Local<Value> env_v = js_options->Get (env->env_pairs_string ());
211+ Local<Value> env_v =
212+ js_options->Get (context, env->env_pairs_string ()).ToLocalChecked ();
199213 if (!env_v.IsEmpty () && env_v->IsArray ()) {
200214 Local<Array> env_opt = Local<Array>::Cast (env_v);
201215 int envc = env_opt->Length ();
202216 options.env = new char *[envc + 1 ]; // Heap allocated to detect errors.
203217 for (int i = 0 ; i < envc; i++) {
204- node::Utf8Value pair (env->isolate (), env_opt->Get (i));
218+ node::Utf8Value pair (env->isolate (),
219+ env_opt->Get (context, i).ToLocalChecked ());
205220 options.env [i] = strdup (*pair);
206221 CHECK_NE (options.env [i], nullptr );
207222 }
@@ -212,31 +227,37 @@ class ProcessWrap : public HandleWrap {
212227 ParseStdioOptions (env, js_options, &options);
213228
214229 // options.windowsHide
215- Local<String> windows_hide_key = env->windows_hide_string ();
230+ Local<Value> hide_v =
231+ js_options->Get (context, env->windows_hide_string ()).ToLocalChecked ();
216232
217- if (js_options-> Get (windows_hide_key) ->IsTrue ()) {
233+ if (hide_v ->IsTrue ()) {
218234 options.flags |= UV_PROCESS_WINDOWS_HIDE;
219235 }
220236
221237 // options.windows_verbatim_arguments
222- Local<String> windows_verbatim_arguments_key =
223- env->windows_verbatim_arguments_string ();
224- if (js_options->Get (windows_verbatim_arguments_key)->IsTrue ()) {
238+ Local<Value> wva_v =
239+ js_options->Get (context, env->windows_verbatim_arguments_string ())
240+ .ToLocalChecked ();
241+
242+ if (wva_v->IsTrue ()) {
225243 options.flags |= UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS;
226244 }
227245
228246 // options.detached
229- Local<String> detached_key = env->detached_string ();
230- if (js_options->Get (detached_key)->IsTrue ()) {
247+ Local<Value> detached_v =
248+ js_options->Get (context, env->detached_string ()).ToLocalChecked ();
249+
250+ if (detached_v->IsTrue ()) {
231251 options.flags |= UV_PROCESS_DETACHED;
232252 }
233253
234254 int err = uv_spawn (env->event_loop (), &wrap->process_ , &options);
235255
236256 if (err == 0 ) {
237257 CHECK_EQ (wrap->process_ .data , wrap);
238- wrap->object ()->Set (env->pid_string (),
239- Integer::New (env->isolate (), wrap->process_ .pid ));
258+ wrap->object ()->Set (context, env->pid_string (),
259+ Integer::New (env->isolate (),
260+ wrap->process_ .pid )).FromJust ();
240261 }
241262
242263 if (options.args ) {
@@ -255,9 +276,10 @@ class ProcessWrap : public HandleWrap {
255276 }
256277
257278 static void Kill (const FunctionCallbackInfo<Value>& args) {
279+ Environment* env = Environment::GetCurrent (args);
258280 ProcessWrap* wrap;
259281 ASSIGN_OR_RETURN_UNWRAP (&wrap, args.Holder ());
260- int signal = args[0 ]->Int32Value ();
282+ int signal = args[0 ]->Int32Value (env-> context ()). FromJust ( );
261283 int err = uv_process_kill (&wrap->process_ , signal);
262284 args.GetReturnValue ().Set (err);
263285 }
0 commit comments