Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: use SPrintF in ProcessEmitWarning #38758

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/node_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "v8.h"
#include "debug_utils-inl.h"
addaleax marked this conversation as resolved.
Show resolved Hide resolved

namespace node {

Expand All @@ -25,10 +26,16 @@ v8::Maybe<bool> ProcessEmitWarningGeneric(Environment* env,
const char* type = nullptr,
const char* code = nullptr);

// Call process.emitWarning(str), fmt is a snprintf() format string
template <typename... Args>
v8::Maybe<bool> ProcessEmitWarning(Environment* env,
const char* fmt,
Args&&... args);
inline v8::Maybe<bool> ProcessEmitWarning(Environment* env,
const char* fmt,
Args&&... args) {
std::string warning = SPrintF(fmt, std::forward<Args>(args)...);

return ProcessEmitWarningGeneric(env, warning.c_str());
}

v8::Maybe<bool> ProcessEmitExperimentalWarning(Environment* env,
const char* warning);
v8::Maybe<bool> ProcessEmitDeprecationWarning(Environment* env,
Expand Down
12 changes: 0 additions & 12 deletions src/node_process_events.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include <cstdarg>
#include <set>

#include "env-inl.h"
#include "debug_utils-inl.h"
#include "node_process.h"
#include "util.h"

Expand Down Expand Up @@ -85,16 +83,6 @@ Maybe<bool> ProcessEmitWarningGeneric(Environment* env,
return Just(true);
}

// Call process.emitWarning(str), fmt is a snprintf() format string
template <typename... Args>
v8::Maybe<bool> ProcessEmitWarning(Environment* env,
const char* fmt,
Args&&... args) {
std::string warning = SPrintF(fmt, std::forward<Args>(args)...);

return ProcessEmitWarningGeneric(env, warning.c_str());
}


std::set<std::string> experimental_warnings;

Expand Down