From 0eef49a6751f29a70e2a59c7010ef212f6ceaa7f Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 26 Nov 2024 08:59:11 -0800 Subject: [PATCH 1/2] feat: Warn on multiple hook initialization --- hook.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hook.js b/hook.js index bbeac27..719f4f0 100644 --- a/hook.js +++ b/hook.js @@ -279,6 +279,12 @@ function createHook (meta) { let includeModules, excludeModules async function initialize (data) { + if (global.__import_in_the_middle_initialized__) { + console.warn("The 'import-in-the-middle' hook has already been initialized") + } + + global.__import_in_the_middle_initialized__ = true + if (data) { includeModules = ensureArrayWithBareSpecifiersFileUrlsAndRegex(data.include, 'include') excludeModules = ensureArrayWithBareSpecifiersFileUrlsAndRegex(data.exclude, 'exclude') From 078ac3aae506563f69961f4200b5eb0ae4e81f34 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Wed, 4 Dec 2024 13:35:58 +0100 Subject: [PATCH 2/2] Use `process.emitWarning` instead of `console.warn` --- hook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hook.js b/hook.js index 719f4f0..1629e72 100644 --- a/hook.js +++ b/hook.js @@ -280,7 +280,7 @@ function createHook (meta) { async function initialize (data) { if (global.__import_in_the_middle_initialized__) { - console.warn("The 'import-in-the-middle' hook has already been initialized") + process.emitWarning("The 'import-in-the-middle' hook has already been initialized") } global.__import_in_the_middle_initialized__ = true