From aa4c57ae7e74a623f5255a7f05a6ff9d5bc335d0 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sun, 24 Nov 2019 12:40:40 +0800 Subject: module: add warnings for experimental flags PR-URL: https://github.com/nodejs/node/pull/30617 Fixes: https://github.com/nodejs/node/issues/30600 Reviewed-By: Guy Bedford --- src/node_process_events.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/node_process_events.cc') diff --git a/src/node_process_events.cc b/src/node_process_events.cc index 06096226625..d192ef19b7a 100644 --- a/src/node_process_events.cc +++ b/src/node_process_events.cc @@ -1,4 +1,5 @@ #include +#include #include "env-inl.h" #include "node_process.h" @@ -95,6 +96,21 @@ Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...) { return ProcessEmitWarningGeneric(env, warning); } + +std::set experimental_warnings; + +Maybe ProcessEmitExperimentalWarning(Environment* env, + const char* warning) { + if (experimental_warnings.find(warning) != experimental_warnings.end()) + return Nothing(); + + experimental_warnings.insert(warning); + std::string message(warning); + message.append( + " is an experimental feature. This feature could change at any time"); + return ProcessEmitWarningGeneric(env, message.c_str(), "ExperimentalWarning"); +} + Maybe ProcessEmitDeprecationWarning(Environment* env, const char* warning, const char* deprecation_code) { -- cgit v1.2.3