From f2a815b3aed42f8f08958216b1ae98c6321b18f3 Mon Sep 17 00:00:00 2001 From: Kyle Herock Date: Sat, 26 Mar 2022 00:41:46 -0400 Subject: [PATCH] Suppress ExperimentalWarning messages --- lib/suppress-experimental.js | 13 +++++++++++++ lib/wrap.js | 1 + test/utils.js | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/suppress-experimental.js diff --git a/lib/suppress-experimental.js b/lib/suppress-experimental.js new file mode 100644 index 0000000..b75e84d --- /dev/null +++ b/lib/suppress-experimental.js @@ -0,0 +1,13 @@ +const { emitWarning } = process; + +process.emitWarning = (warning, ...args) => { + if (args[0] === 'ExperimentalWarning') { + return; + } + + if (args[0] && typeof args[0] === 'object' && args[0].type === 'ExperimentalWarning') { + return; + } + + return emitWarning(warning, ...args); +}; diff --git a/lib/wrap.js b/lib/wrap.js index ca33259..d99186f 100755 --- a/lib/wrap.js +++ b/lib/wrap.js @@ -13,6 +13,7 @@ const { extensions, fork, vm } = getConfig(script); if (process.env.NODE_DEV_PRELOAD) { require(process.env.NODE_DEV_PRELOAD); } +require('./suppress-experimental'); // We want to exit on SIGTERM, but defer to existing SIGTERM handlers. process.once('SIGTERM', () => process.listenerCount('SIGTERM') || process.exit(0)); diff --git a/test/utils.js b/test/utils.js index 3259146..9b5ba4e 100644 --- a/test/utils.js +++ b/test/utils.js @@ -10,7 +10,7 @@ const dir = join(__dirname, 'fixture'); const reClear = new RegExp(control); exports.spawn = (cmd, cb) => { - const ps = spawn('node', [bin, '--no-warnings'].concat(cmd.split(' ')), { cwd: dir }); + const ps = spawn('node', [bin].concat(cmd.split(' ')), { cwd: dir }); let err = ''; function errorHandler(data) {