@@ -2562,6 +2562,33 @@ void ClearFatalExceptionHandlers(Environment* env) {
2562
2562
Undefined (env->isolate ())).FromJust ();
2563
2563
}
2564
2564
2565
+ // Call process.emitWarning(str), fmt is a snprintf() format string
2566
+ void ProcessEmitWarning (Environment* env, const char * fmt, ...) {
2567
+ char warning[1024 ];
2568
+ va_list ap;
2569
+
2570
+ va_start (ap, fmt);
2571
+ vsnprintf (warning, sizeof (warning), fmt, ap);
2572
+ va_end (ap);
2573
+
2574
+ HandleScope handle_scope (env->isolate ());
2575
+ Context::Scope context_scope (env->context ());
2576
+
2577
+ Local<Object> process = env->process_object ();
2578
+ MaybeLocal<Value> emit_warning = process->Get (env->context (),
2579
+ FIXED_ONE_BYTE_STRING (env->isolate (), " emitWarning" ));
2580
+ Local<Value> arg = node::OneByteString (env->isolate (), warning);
2581
+
2582
+ Local<Value> f;
2583
+
2584
+ if (!emit_warning.ToLocal (&f)) return ;
2585
+ if (!f->IsFunction ()) return ;
2586
+
2587
+ // MakeCallback() unneeded, because emitWarning is internal code, it calls
2588
+ // process.emit('warning', ..), but does so on the nextTick.
2589
+ f.As <v8::Function>()->Call (process, 1 , &arg);
2590
+ }
2591
+
2565
2592
2566
2593
static void Binding (const FunctionCallbackInfo<Value>& args) {
2567
2594
Environment* env = Environment::GetCurrent (args);
0 commit comments